Show SubGrid row based on Master Table Selection

QuestionsShow SubGrid row based on Master Table Selection
Michael Sheppard asked 2 years ago

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”;


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.




4 Answers
Abu Ghufran Staff answered 2 years ago


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.

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Michael answered 2 years ago

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.

Abu Ghufran Staff answered 2 years ago

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.

Abu Ghufran - Dev Team
Grid 4 PHP Framework
Michael answered 2 years ago

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


Your Answer

19 + 13 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?