I am very new to JQuery and JStree, i am trying to use Jstree and trying to sort the nodes. But system is not executing sort function. Please can you help in fixing the issue.
Here is the java script code and XXXXXXXXXX is variable replaced with JSON data for tree to be populated.
<script type="text/javascript">
$(function() {
$("#tree").on('changed.jstree', function (e, data) {
var datainstance = data.instance.get_node(data.selected);
changeProduct(data.selected,datainstance.original.attr.type);
}).jstree(XXXXXXXXXX,{
"sort" : function (a, b) {
alert("gggg");
return get_node(a).original.attr.type > get_node(b).original.attr.type ? 1 : -1;
}},
{"plugins" : [ "sort"]});
});
System is displaying the tree view correctly and all nodes are correct, except sorting. Here sorting should be done based on type.
See also the attached file of JSON and displayed tree below
Any help is very much appreciated
"sort" :
The curly brace should not be there, please paste the real data - just use "view source" and paste all of the tree's config (remove the "data" part).
Best regards,
Ivan