Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » std.list3 passing middle table to child form
std.list3 passing middle table to child form [message #366] Tue, 07 November 2006 04:31 Go to next message
johandewit is currently offline  johandewit
Messages: 25
Registered: May 2006
Location: Belgium
Junior Member
Getting one step further in my list3 problem, i'm still confused.
(see also for reference
http://www.radicore.org/forum/index.php?t=msg&th=116& ;start=0&S=0d875c7d23340dd2e17ef9c779399d89 )

How does one get the data from the middle table passed to the std.add2 child form ? In my case, I only get the $where from the "outer" or parent table. Since the middle table contains also a field (the weeknumber) that is needed in the grandchild - inner table, i'm looking for a way to pass the value to the next form. But here I'm lost.

See the screenshot in previous post, I choose for the list3 for following reason :

Outer -> user data is fixed, and the data is retreived using the logon id from the user.

Middle -> contains some overview data for the slected week. More than 1 week can be available, so scrolling is possible.

inner -> the detailed inoput data for the selected week middle table.


Johan
Re: std.list3 passing middle table to child form [message #367 is a reply to message #366] Tue, 07 November 2006 06:44 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2350
Registered: April 2006
Location: Surrey, UK
Senior Member
If you go to home->prototypes->classroom scheduling->rooms and make a selection followed by the "Maintain Schedule" button you will see a working example of what you are trying to do. The middle table there is a dummy table, just like yours.

When I hit the "New" button it makes the current selection in the middle table available to the child ADD screen, which is the behaviour that you want. Although that screen uses the MULTI3 pattern I have tried it with LIST3 and it works just the same.

I suggest you look at this transaction to see how it is done.


Re: std.list3 passing middle table to child form [message #386 is a reply to message #367] Thu, 09 November 2006 04:18 Go to previous messageGo to next message
johandewit is currently offline  johandewit
Messages: 25
Registered: May 2006
Location: Belgium
Junior Member
Managed to get the data from std.lsit3 to the child form std.add2.

From the Menu, I call the std.list3. So, I needed a $where, which I create in the outer_class using the _cm_initialize function.

Since the logon_id is not a primary key in my user database, I needed to look this up to create the $where string using the primary key.

the code from the _cm_initialize function

if (!empty($_SESSION['logon_user_id'])) {
$where = 'log = "' . strtolower($_SESSION['logon_user_id']) . '"';
if ($this->getCount($where) == 1 )
{
$fieldarray = $his->getData_raw($where);
$where_array= $this->getPkeyArray($fieldarray);
$where = array2where($where_array);
} else {
$where= NULL; // not a regular user
}
}

[ Or should one use the Task Parameter 'Selection (fixed) in menu and RBAC system ? ]

The middel tabel is dericed from the inner table and contains mostly calculated fields. The problem I had, was that I needed to pass a calculated field, which is defined in the inner table, which is not a primary key.

When addin new records to the inner table, the fields from the middle table must be filled in already and changed to 'noedit' state.

Such data is passed using the $where string. This where string consist only of pkey fields. In the middel table, I modified the propertie $this->primary_key to include all fields nedded for the child form (std.add2 in my case). This is done in the _cm_changeConfig function in the middel_table_class.

IIs this the intended way for this situation, or are there better ways to achieve the same ?

Thanks

Johan




Re: std.list3 passing middle table to child form [message #387 is a reply to message #386] Thu, 09 November 2006 05:09 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2350
Registered: April 2006
Location: Surrey, UK
Senior Member
Your method of building the $where string from $_SESSION['logon_user_id'] is the approach I would have used. It would not be possible to use the Task Parameter 'Selection (fixed)' in the RBAC system as you can only specify a fixed string, not construct one from a variable.

The method of modifying the primary key details in the middle table so that the correct values are passed to the inner table is what I actually use in table class 'crs_schedule_x01.class.inc', which is used in the example I gave you. The code is:
function _cm_changeConfig ($where, $fieldarray)
{
    // temporarily define a different primary key
    $this->primary_key = array('schedule_id', 'room_id', 'day_no');

    return $fieldarray;

} // _cm_changeConfig

That's one of the advantages of getting the table specifications from the contents of the <table>.dict.inc file which is exported from the Data Dictionary - the contents can be modified at any time. That would not be possible if I read the primary key directly from the database because then I would be stuck with the database definiton. With my method I can change any of those details, so there is MUCH more flexibility.


Re: std.list3 passing middle table to child form [message #388 is a reply to message #387] Thu, 09 November 2006 05:16 Go to previous message
johandewit is currently offline  johandewit
Messages: 25
Registered: May 2006
Location: Belgium
Junior Member
My mistake in the cm_changeConfig :

I used $this->fieldspec['fieldname']['pkey'] = 'y';
but the $this->primary_key MUST be used.

Thanks a lot for helping me.

johan
Previous Topic: File picker
Next Topic: Debug application
Goto Forum:
  


Current Time: Fri Jun 14 15:34:14 EDT 2024

Total time taken to generate the page: 0.01106 seconds