Reputation: 158
When I'm invoking the event "reloadGrid" event like this for subgrid
$('#subgrid_id').trigger("reloadGrid");
The parent grid is reloading as well collapsing the subgrid and delete all the subgrid HTML code.
How Can I prevent this behavior and reload only the subgrid?
I'm using jQgrid 4.5.2.
Upvotes: 0
Views: 1097
Reputation: 221997
You should verify how you build id of subgrid inside of subGridRowExpanded
callback. It you work with subgrids, it's extremely important to hold full control about all ids of subgrids and all rowids of main grid and subgrids. All the ids must be unique. You should construct the id of subgridgrid based on the first parameter of of subGridRowExpanded
callback or alternatively by calling the method $.jgrid.randId()
which returns unique id on every call.
I strictly recommend you to use additionally unique idPrefix
option for subgrid. You can build the value of idPrefix
option based on input parameters of subGridRowExpanded
callback. The rowid will then build based on the id of data, but the ids will have the prefix. For example you can use the second parameter is rowid
with some suffix like idPrefix: rowid + "_s_"
. So if your ids of the data of the main grid are 10,20,30... and the data of subgrid contains ids 10,15,20 then jqGrid you will use rowids of subgrids: 20_s_10
, 20_s_15
, 20_s_20
for the subgrid by opening the row with id 20 of the main grid. I hope that I don't confuse you with the example. In any way I recommend you to open 2-3 subgrids of your grid and to examine carefully which ids have every subgrid and rows of main grid rows of subgrids. You should find no id duplicates.
Upvotes: 1