Get KoolPHP UI with 30% OFF!

Inserting (adding) rows to child grids

T
Looking for some sample code for inserting (adding) rows to child grids (in a hierarchy) that will auto-populate (or pre-populate in a form) the foreign key, as that value is required in order to insert rows into the 'child' table. The master (parent) row in the hierarchy contains and displays the correct value in the master grid, however I cannot figure out how to access that particular value through the framework. I can query the database and get a value out of the foreign key column from the master table, however it is from the first row in the table, not the row that pertains to the master-child relationship of interest. I have spent several hours looking through the documentation and code but no luck. Any help would be appreciated.
Posted Jul 22, 2016 , edited Jul 22, 2016 Kool
Riho Ellermaa
In my child grid I use
$players->AddRelationField("team_id", "id");
where id is the id of team in the master grid and team_id is the related field in the child grid
And in child grid dataasource:
$dsPlayer->InsertCommand = "insert into ejl_registration(player_id,team_id,position_id)
values(@playerid,@team_id,@position_id)";
playerid and position_id are getting values from GridBoundColumns and team_id gets it automatically from master grid
Posted Aug 22, 2016 Kool