Search code examples
javascriptjqueryajaxjqgridtreegrid

JQGrid tree - passing additional parameters when tree is expanded


I have a JQGRid tree. It loads data click by click, not all at once.

Typically, JQGRid passes 4 standard tree parameters with each call - row (level, parent, is leaf, is expanded). How can I pass more parameters that I will take from the row being expanded? E.g. data from Name column should be passed in AJAX call too. There doesn't seem to be OnExpand event or similar.


Solution

  • This is resolved by editing grid.treegrid.js

    Method:     expandNode : function(rc) {
    Lines: 344-355
    

    There we can insert custom query parameters before ajax call is made, into PostData array. E.g.

    data = $(this).jqGrid("getRowData", rc.id);
    $(this).jqGrid("setGridParam",{postData:{customParam:escape(data.SomeColumn),nodeid:rc.id,parentid:rc.parent_id,n_level:rc.level}});