Reputation: 219057
I have a multiselect jqGrid with a multiselect grid-as-subgrid. In the onSelectRow
event for the parent grid, how can I grab a reference to the child grid?
Essentially, I need to do the following:
onSelectRow
and repeat the process. Don't worry, the grid is no more than 3 nestings deep.)I'm looking through the various documentation this morning, but so far haven't spotted what I need to make this happen. Maybe I'm just missing the obvious? Or maybe this would require a bit more cleverness?
I see how Step 3 above can be accomplished starting with getRowData()
and looping through the results with setSelection()
. I use those elsewhere in code and they work great. But Steps 1 and 2 above are where I'm stuck at the moment.
Edit: Following @Oleg's answer below, I looked a bit more into synchronizing efforts between a parent grid's onSelectRow
event and subGridRowExpanded
event. Here's a boiled down version of what I'm testing right now:
onSelectRow: function(id, status) {
// Automatically expand the sub-grid (to load the data) and select the rows in that grid
autoSelecting = true; // autoSelecting is a global variable normally set to false
$('#mainGrid').expandSubGridRow(id);
}
subGridRowExpanded: function(subgrid_id, row_id) {
//... build the sub-grid, works fine (an artifact of which is a subgrid_table_id)
// If this grid was auto-expanded to be auto-selected, select all its rows
if (autoSelecting) {
var sdata = $('#' + subgrid_table_id).getRowData();
for (var i = 0; i < sdata.length; i++) {
$('#' + subgrid_table_id).setSelection(sdata[i].Id);
}
autoSelecting = false;
}
}
A few things are happening here as I tinker with this:
Upvotes: 0
Views: 3070
Reputation: 222017
Inside of loadComplete
event handler the grid is loaded and you can do some additional actions like expanding of some rows.
subGridRowExpanded
event. You don't posted the JavaScript code which you use, so it is difficult to describe all more exactly.setSelection
in the loop or use code like $('.cbox', myGrid[0]).trigger('click');
There are different other variation how to do the same. If you will see that you have performance bottleneck here then I could describe how you can do the step more effective.I can repeat, that the most important that you expand or select the rows after the grid data (or the subgrid data) is loaded.
Upvotes: 1