I am trying to implement your solution for checking a record in the master-grid to load the Sub Grid data. It works, however it brings-up the loading page and keeps flashing off and on the Loading Page pop-ups. Almost like a loop.
Note – this is a 3-sub report page and I am trying to display content in both the second and third subgrids based on the Master grid – which only returns a single result (URL FIltering).
I have added the Onload to the Events:
$e[“js_on_load_complete”] = “grid_onload”;
$grid->set_events($e);
And I have added the following JScript:
function grid_onload(ids)
{
var ids = $(“#list1”).jqGrid(‘getDataIDs’);
setTimeout( function(){ jQuery(‘#list1’).jqGrid(‘setSelection’, ids[0], true); },100);
}
Please advise.
Thanks
Mike
Hello,
I’m unable to understand why you are using setSelection. Basically It is creating loop as setSelection will reload grid and which will again call setSelection.
If you can explain the scenario and what you are trying to achieve, I can suggest better.
PS: More grid related code will help.
I was using the steps from this post, to select the first-row of the Master Grid:
My goal is to use URL based filtering to display a single record in the Master Report and have the sub-reports display based on the Master Report Record. This is for a ticket-system where I want the user to add a comment in the sub-report.
Right now when I load the report with the URL, the Main Report displays the correct record but the sub-report does not display anything until the user clicks the row in the Master Report.
Does that make more sense? Basically I need to simulate someone clicking the first-row of the Master Grid and having the sub-grid reference correctly to that selected row.
Ok, I understand it better now.
Looks like you have attached onload event with the subgrid. It should be only with the master grid.
Also check if $e, $grid variables are not reused again in subgrid without resetting. This might be setting onload event on subgrid as well.
All these are just my thoughts. Please recheck it and if it does not help, Please share the grid code.
Excellent response – the key was the $e / $grid variables. I wasn’t resetting them in the sub-grids and I do have a custom insert/update function for each. I didn’t realize I needed to reset them for each Grid – but that was the key. Now the report successfully selects the first-row when loaded which populates the Sub-grids for me. And with my URL based filtering, only one ticket shows-up and is now selected.
Excellent response and it’s solved the issue perfectly!
Thanks again
Mike