javascript - FancyTree load all nested children on select -


here's issue. i'm using checkboxes , lazy load via ajax. however, if check parent item without expanding it, none of child nodes have been loaded don't checked. how can load child , nested child nodes under parent, , check them all, when check parent? thanks, , have far

$(function () {     // create tree inside <div id="tree"> element.     $("#tree").fancytree({         source: { url: "/home/getdata", cache: true }         , checkbox: true         , icons: false         , cache: true         , lazyload: function (event, data) {             var node = data.node;             data.result = {                 url: "/home/gettreeviewdata/" + node.key                 , data: { mode: "children", parent: node.key }                 , cache: true             };         }         , selectmode: 3         , select: function (event, data) { //here's need load children , sub children node, if has them, can set checked          }         , strings: {             loading: "grabbing places , events…",             loaderror: "load error!"         },     }) }); 

update reason need pull these client side because treeview loading google map markers. if have structure like

parent1
->child1-1
->->child1-1-1
->child1-2

all of child nodes load lazy. however, if check parent node 1, i'd need load markers of child nodes. that's why i'm looking way recursively children. because hard keep track of markers have/haven't been added, if don't load treeview items , check boxes. make sense?

i think use select event:

select: function(event, data) {     var node = data.node;      if (node.isselected()) {         if (node.isundefined()) {             // load , select child nodes             node.load().done(function() {                 node.visit(function(childnode) {                     childnode.setselected(true);                 });             });         } else {             // select child nodes             node.visit(function(childnode) {                 childnode.setselected(true);             });         }     } } 

that way if child nodes haven't been loaded loaded , selected after that.


Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -