JqGrid reloadGrid keep colapse expand Subgrid

I have a Grid containing a subGrid. Both grids have a Checkbox column. When I click on the parent checkbox, it automatically checks / deselects all the checkboxes of the subheadings. All flags are mapped to DB values, so every time the status changes, it changes the value in the database and I reload the grid to update the status of the flags.

The problem is that when I reinstall the grids, I lose the extended sub-series, which is very annoying, because every time I click on the checkbox, it reloads the grids ...

Is there a way to keep the status of which row is used up when reloading grids?

Here is part of my codes:

$('#jqgSearchTaxPayer').jqGrid({ .... subGrid: true, subGridRowExpanded: function (sendSubGrid, lineId) { var sendSubGridId; sendSubGridId = sendSubGrid + "_t"; $("#" + sendSubGrid).html("<table id='" + sendSubGridId + "' class='scroll'></table>"); $("#" + sendSubGridId).jqGrid({ .... { name: 'Keep', index: 'Keep', width: '9px', align: 'center', editable: true, edittype: 'checkbox', formatter: function (cellvalue, options, rowObject) { cellvalue = cellvalue + ""; cellvalue = cellvalue.toLowerCase(); var bchk = " checked=\"checked\""; if (cellvalue == "false") { bchk = ""; } return "<input type='checkbox' onclick=\"SendLineChecked('" + options.rowId + "','" + sendSubGrid + "');\" " + bchk + " value='" + cellvalue + "' offval='no' />"; }, formatoptions: { disabled: false } }], .... 

Thanks in advance for your help!

+4
source share
1 answer

I found a solution inspired by this post.

Declare a function that will receive the entire string that is currently expanded and cause a reboot

 var scrollPosition = 0; var ids = []; function RefreshGridData() { var num; ids = new Array(); $("#jqgSearchTaxPayer tr:has(.sgexpanded)").each(function () { num = $(this).attr('id'); ids.push(num); }); $("#jqgSearchTaxPayer").trigger("reloadGrid"); } 

In the GridComplete () function of the main grid, analyze a collection of rows and expand it

 gridComplete: function () { for (var j = 0; j < ids.length; j = j + 1) { $("#jqgSearchTaxPayer").jqGrid('expandSubGridRow', ids[j]); } }, 
+2
source

All Articles