The solution seems very easy for me. One need just make small modification from the code from the answer which you reference. You can do something like the following
var orgExpandNode = $.fn.jqGrid.expandNode;
$.jgrid.extend({
expandNode: function (rc) {
// here you can insert the code which will be executed
// before the original expandNode
var res = orgExpandNode.call(this, rc);
// now you can execute some code after the original expandNode
// for example the next line hide the node in the grid
$("#1_1_1").hide(); // hide some row of the grid
return res; // return the value from expandNode
}
});
see the demo. The demo has one node in the TreeGrid which has id="1_1_1"
, but it stay hidden all the time.
UPDATED: Free jqGrid have beforeExpandRow
, afterExpandRow
, beforeExpandNode
and afterExpandNode
callbacks and "jqGridTreeGridBeforeExpandRow"
, "jqGridTreeGridAfterExpandRow"
, "jqGridTreeGridBeforeExpandNode"
, "jqGridTreeGridAfterExpandNode"
events. Thus subclassing of TreeGrid methods described above is not required in case of usage free jqGrid.