Reputation: 11705
I'm using this plugin to get a tree-view table: http://ludo.cubicphuse.nl/jquery-plugins/treeTable/doc/
It works great, except for one thing that I need, which is lazy loading of content.
It does provie a callback feature for when a folder is opened, which I then use to fetch the freshly opened branch and use an ajax call to populate it with data. It works great filling in the table, but the added rows don't conform to the indented structure they should.
A call to jQuery('#tree-table').treeTable({}); after the additional rows are added results in proper indentation, but it also collapses the tree, which is annoying to user navigating down a deep path.
Has anyone else attempted to do anything similar with treeTable?
Upvotes: 4
Views: 6276
Reputation: 7
var orgExpandNode = $.fn.jqGrid.expandNode,
orgCollapseNode = $.fn.jqGrid.collapseNode;
$.jgrid.extend({
expandNode : function(rc) {
if(this.getNodeChildren(rc).length===0){
$.ajax({
url : "http://localhost:8080/xxxx",
success : function(data) {
var result = data;
for(var i=0;i<result.length;i++){
grid.addChildNode(result[i].id,result[i].parent,result[i]);
}
result=[];
}
});
}
return orgExpandNode.call(this, rc);
},
});
Upvotes: 0
Reputation: 21
There is an issue on GitHub concerning Lazy Loading, that might help: https://github.com/ludo/jquery-treetable/issues/24
Upvotes: 2
Reputation: 6115
it looks like you will want to use either:
expand : Recursively show all node's children in a tree.
reveal : Reveal a node by expanding all ancestors.
functions which they offer in their API. Once you add the new branch, make sure you save a reference to it, and then after you re-initialize then call a function to get it to show (probably reveal() in this case).
Upvotes: 0