Jqgrid Treegrid在更新本地源数据时重新加载节点

时间:2013-11-22 20:47:46

标签: javascript jquery node.js jqgrid

我创建了一个包含本地数据的Treegrid

$("#historyGrid").jqGrid({
    datatype: "jsonstring",
    datastr : treeGridObject ,
    colNames:["Id","Channel","Current","History","Delta"],
    colModel:[
        {name:'id', index:'Id', width:120, hidden : true , key:true},
        {name:'channel', index:'Name', width:180},
        {name:'current', index:'Current', width:80},
        {name:'history', index:'History', width:80},
        {name:'delta', index:'Delta', width:80}

    ],
   height: 'auto'  ,
    gridview: true,
    rowNum: 10000,
    sortname: 'id',
    treeGrid: true,
    treeGridModel: 'adjacency',
    treedatatype: "local" ,
    ExpandColumn: 'channel' ,

    treeReader: {
        level_field: "level",
        leaf_field: "isLeaf",
        expanded_field  : "expanded"

      }

});  

我必须在点击动态加载的特定父节点时添加子节点。为此,在更新本地源数据后应该怎么做 现在我在更新源数据(添加行信息)后调用下面的行。这似乎重新加载了整个treegrid。有没有办法我只能重新加载我点击的节点?

$("#historyGrid")[0].addJSONData({
                       total: 1,
                       page: 1,
                       records: treeGridObject.length,
                       rows: treeGridObject
                   });

我已经尝试$("#historyGrid").addChildNode(treeGridRow.id , rc._id_ , treeGridRow);这不起作用。

1 个答案:

答案 0 :(得分:1)

你能这样试试吗?

$("#historyGrid").jqGrid('addChildNode', treeGridRow.id , rc._id_ , treeGridRow);