When I first load the master-detail grids, the detail grid is empty until a master record is selected that has a related detail record. When the master grid is reloaded, the previous detail record remains selected even though there is no selected master record.
How can this be prevented.
Thanks
Hello,
I am unable to generate this issue. When we refresh master grid, all related details grids are refreshed.
However it is possible that the default sql in detail grid may be showing some results, otherwise it should show blank.
I'm also emailing you latest build and sample code.
The latest build you sent added "Columns" to the toolbar but did not improve my master reload issue where the previously selected detail record remains.
All of your master-detail examples show a master without any col parameters assigned – $col = array();. I have too many columns in my master so have specifically assigned some columns to display where others are all hidden, although most are editable. Because columns are adjusted, I use
$g->set_columns($cols);
$out_master = $g->render("list1");
to display and render the master.
For the detail, I also assign columns for the same reason. When I used the same logic to display and render, I always got the assigned master columns as well as the detail columns on the detail grid. I thought that this might be happening because of the use of $g->set_columns($cols) in the detail; which would use the same var $cols as the master.
So, I modified the detail columns to $col1 and used
$g->set_columns($cols1);
$out_detail = $g->render("list2");
to display and render the detail.
This fixed the separation of the master and detail columns.
So, could either of these 2 scenarios be causing my reload issue which leaves the detail record displayed.
1. Using specific $col params in the master, which you do not use in the examples.
2. Using $cols and $cols1 in the master and detail respectively.
Or, is there anything else I should look for?
When I first load the master-detail grids,
The detail grid is empty until a master record is selected (click)
that has a related detail record.
Sorry no english
Hello,
It is designed to work this way.
What is your requirement. I can help after that.
I have the same issue that miguel Molina. I have a master grid and a detail grid.
I would like to be selected automatically the first row of the master grid and the detail grid is loaded with data according to the master´s selected row.
I've only managed to do the first part, with this code:
$e["js_on_load_complete"] = "grid_onload";
$g0->set_events($e);
…
function grid_onload(ids)
{
var grid = jQuery("#list0");
var ids = grid.jqGrid('getDataIDs');
// Select first row
jQuery("#list0").setSelection (ids[0], true);
}
The master grid´s first row is selected, but the detail grid does´nt load data. Can you help me to resolve this?
Use some delay when calling setSelection. e.g.
Replace:
jQuery("#list0").setSelection (ids[0], true);
With:
setTimeout( function(){ jQuery('#list0').jqGrid('setSelection', ids[0], true); },500);