Home › Forums › Guriddo jqGrid JS › Help › The “subGridRowExpanded” event returns the wrong row ID.
Tagged: #collapseSubGridRow, Subgrid, subgridrowexpanded
The “subGridRowExpanded” event returns the wrong row ID if the grid row was collapsed using the “collapseSubGridRow” method.
Hello,
Such kind of description of the problem will not help you.
In order to get quality support you will need to prepare a working test case.
You can publish it here, send it to support team or prepare online version.
Please note the phrase – working test case
Kind Regards,
Will
Guriddo Support Team
The aim is to close an already expanded row when a new row expands.
Step to reproduce the issue.
Step1: Exapand any row.
Step2: Now expand any other row, the value “id” from “subGridRowExpanded” event got the incorrect row id.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
var last_expanded_row_id; $("#grid").jqGrid({ datatype: 'local', data: myGridData, colNames: ['Column 1', 'Column 2'], colModel: [ { name: 'col1', width: 200 }, { name: 'col2', width: 200 } ], ... subGrid: true, subGridBeforeExpand: function(pID, id) { if(last_expanded_row_id !== undefined) { $("#grid").collapseSubGridRow(last_expanded_row_id); } }, subGridRowExpanded: function (pID, id) { //here id receives incorrect row id. $("#"+pID).html(pID+ "_t"); $("#"+pID+"_t").jqGrid({ datatype: 'local', data: mySubgrids[id], colNames: ['Col 1', 'Col 2', 'Col 3'], colModel: [ { name: 'c1', width: 100 }, { name: 'c2', width: 100 }, { name: 'c3', width: 100 } ], ... }); last_expanded_row_id = id; } }); |
Hello,
Thank you for the test case. It is much easier to solve this way the problem.
The problem appear in subGridBeforeExpandRow which triggers a click which actually forces the expandGridRow (Catch 22)
To solve the problem use the following trick:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
$("#grid").jqGrid({ datatype: 'local', data: myGridData, colNames: ['id','Column 1', 'Column 2'], colModel: [ { name: 'id', hidden: true, key: true}, { name: 'col1', width: 200 }, { name: 'col2', width: 200 } ], subGrid: true, height: 400, subGridBeforeExpand: function(pID, id) { if(last_expanded_row_id !== undefined) { setTimeout(function() { $("#grid").collapseSubGridRow(last_expanded_row_id); }, 50); } }, subGridRowExpanded: function (pID, id) { var childGridID = pID + "_table"; var childGridPagerID = pID + "_pager"; $('#' + pID).append('<table id=' + childGridID + '></table><div id=' + childGridPagerID + ' class=scroll></div>'); $("#" + childGridID).jqGrid({ datatype: 'local', data: mySubgrids[id], colNames: ['Col 1', 'Col 2', 'Col 3'], colModel: [ { name: 'c1', width: 100 }, { name: 'c2', width: 100 }, { name: 'c3', width: 100 } ], gridComplete : function() { setTimeout(function() { last_expanded_row_id = id;},1000); } }); } }); |
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top