Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery jqgrid treegrid expand to a specific level
    primarykey
    data
    text
    <p>This is a question for jQuery jqGrid. We need a function to expand a treegrid to a certain level. I tried directly using collapseRow, expandRow, collapseNode and expandRow. But, the collapseRow/expandRow are recursive. So, it was really slow to call these functions at every row. Therefore, I added hideRow and showRow functions to jqgrid. I succeeded expand and collapse the tree to a certain level. However, when tree is expanded say to level 3, if you close your tree by clicking the triangle at the top level. Some expanded rows are still there.</p> <p>This is the functions I added under jqgrid.</p> <pre><code>hideRow: function (record) { this.each(function(){ $( this.rows.namedItem(record.id)).css("display","none"); }); }, showRow: function (record) { this.each(function(){ $( this.rows.namedItem(record.id)).css("display",""); }); }, </code></pre> <p>This is how I called these functions. (I omitted some contexts, but that shouldn't be the road block.)</p> <pre><code>var len = me.gjson.datastr[me.reader_root].length; for (var i=len-1; i&gt;-1; i--) { var one_node = jQuery(me.gid).getInd(i+1,true); one_node._id_ = one_node.id; if (parseInt(me.gjson.datastr[me.reader_root][i].level)&lt;me.expand_level) { jQuery(me.gid).jqGrid('expandNode',one_node); } else { jQuery(me.gid).jqGrid('collapseNode',one_node); } } for (var i=0; i&lt;len; i++) { var one_node = jQuery(me.gid).getInd(i+1,true); one_node._id_ = one_node.id; if (parseInt(me.gjson.datastr[me.reader_root][i].level)&lt;me.expand_level+1) { jQuery(me.gid).jqGrid('showRow',one_node); } else { jQuery(me.gid).jqGrid('hideRow',one_node); } } </code></pre> <p>I traced into the jqGrid code. It shows that the "expanded" value was set correctly within collapseNode/expandNode. But, when you click the triangle at top level to collapse the whole tree, value "expanded" was set to something else. So, the question is what could be the cause? Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload