Sorting and SmartRendering

Hi,
I’ve some trouble with dhtmlxTree and sorting method. My tree is loaded with method enableSmartRendering(), and when I sort a node with some children not displayed yet, the sortTree method fail : The first elements displayed are blank.

here is my code :

<input type="button" value="Sort Branch ASC" onclick="sort_branch('asc');"/>
<input type="button" value="Sort Branch DESC" onclick="sort_branch('desc');"/>
<div id="treebox" style="width:280px; height:500px; "></div>

<script>
function sort_branch(AOrder){
	dhxTree.sortTree(dhxTree.getSelectedItemId(),AOrder);
}

dhxTree=new dhtmlXTreeObject('treebox',"100%","100%",0);
dhxTree.setSkin('dhx_skyblue');
dhxTree.setDataMode("json");
dhxTree.setImagePath("../dhtmlxSuite/dhtmlxTree/codebase/imgs/");
dhxTree.enableSmartRendering(true);
dhxTree.loadJSON("db/main.json");
</script>

Concerning my tree structure, I’ve 5 nodes on first level, one of them has 5000 children.
If I open the node with 5000 children and make a sort asc or desc on it, the error appears.

If someone has an idea ?

Thanks.

Hi
Sorting isn’t supported in the Tree in the SmartRendering mode, but in TreeGrid it is supported. If you have a PRO suit you can use TreeGrid.

Hi,
Is it possible to load the complete node before sorting ? is there a method to do that ?

Thanks

Hi I finally apply your solution,
I made a sort of objects in my DB on server side, then on client side I use deleteChildItems(0), and refresh the branch with smartRefreshBranch method. It works fine, thanks.

It is a good solution too.
You are welcome!