I have Grid with a subgrid using subGridRowExpanded.
And I want to dynamically expand some rows of the grid so I wrote following in GridComplete Event of First Grid. ids is array of row ids of my Grid
for(int i =0; i< ids.length; i++) {
//Checking with condition
$("#myGridName").expandSubGridRow(ids[i]);
}
I also tried with following code, But for some reason checkboxes in GridComplete of second level, is added only for last expanded row.
$("#myGridName").expandSubGridRow(ids[0]);
$("#myGridName").expandSubGridRow(ids[1]);
Above code expands appropriate rows. But,
In GridComplete event of Subgrid, I've check boxes in each row.
So, Here I need to check some of the Chekc boxes.
But the Problem is,
The subgrid_row_id is getting wrong
i.e. ID of last subgrid to be expanded is assigned in SubGridRowExpanded of Parent Grid.
Note : I manually adding checkboxes to each row in subgrid
Thanks in Advance.
If I understand you correct you have very close problem as discussed in the answer. What you try to do seems the same what expandOnLoad: true property of the
subGridOptions
option should do. Like I described in the answer jqGrid don't support queuing of Ajax requests. If you executewith remote
datatype
orsubgridtype
('json' or 'xml') the Ajax request will be sent to the server. Till we receive the corresponding response from the server the internal propertywill be set to
true
and all other Ajax requests for example from$("#myGridName").expandSubGridRow(ids[1])
will be just skipped (ignored).The same problem (bug) exist in the current implementation of
expandOnLoad: true
. If you open in the official jqGrid demo the "Hierarchy (4.0) new" tree node and then look at the demo "Expand all Rows on load" you will see that not all rows are correctly expanded as promised (you have to scroll the grid to see all subgrids).I think that to implement expanding of subgrids on load correctly you should do about the following
I can recommend you to use
success
callback function ofajaxSubgridOptions
jqGrid options because there are noloadComplete
event after loading the subgrid. The current implementation of the Ajax request in subgrid usescomplete
callback function of jQuery.ajax (see here) which will be called beforesuccess
callback. So you can define yoursuccess
callback as the method of theajaxSubgridOptions
option of jqGrid. Inside of thesuccess
callback you can call$("#myGridName").expandSubGridRow(ids[i])
for the next node (if any still not expanded). In the way you can open all subgrids.To enumerate subgrids more effectively the answer could be helpful for you.