Topic: update clicked node label and on demand json

Hello,

I've implemented onDemand JSON to load my tree level by level.
I need to update the title of the clicked node to add number of child nodes between parenthesis after JSON children loading.

Thank you for the help.

Re: update clicked node label and on demand json

yourTree.addEvent('loadChildren', function(parent){
    parent.set({
        property:{
            name: parent.name+' ('+parent.children.length+')'
        }
    });
});

Re: update clicked node label and on demand json

Seems that this event is incompatible with refreshChildren function ...
When I set loadChildren event and if I call the refreshChildren function it seems that execution stop before get json data ...

    refreshChildren: function() {
                        this.state.loaded=false;
                        this.state.open=false;

                        this.state.loadable=true;
                        this.children=[];
                           this.$draw=false;
                        this.tree.$getIndex();
                        this.getDOM('children').innerHTML='';
                        Mif.Tree.Draw.update(this);
                        return this;
                 },

Re: update clicked node label and on demand json

i'm fix some bugs and add "reload children and update clicked node name" demo

Re: update clicked node label and on demand json

works well except that refreshChildren it should'nt collaspe opened nodes ...
the method should refresh preserving state of nodes

Re: update clicked node label and on demand json

I would like to copy current this.state  property inside refreshChildren method to be able to restore state after refresh.
What happens is this.state.open value is always false ?????

Re: update clicked node label and on demand json

works well except that refreshChildren it should'nt collaspe opened nodes ...

refreshChildren means that you load new nodes and they know nothing about old nodes and their states. You should manualy find which nodes is the same as old (and defined what it means "same nodes") and restore their states.

Re: update clicked node label and on demand json

Yes ! As I told you seems that this.state.open value in refreshChildren method is alway false ... So I can't save the state.
In all case It would be nice to have something that track opened node and a method to restore the state quickly.
A cookie will be very usefull to keep state too...

Re: update clicked node label and on demand json

Can you give a trick to solve this ?

Re: update clicked node label and on demand json

need some time to create this functionality, not now, mb next week.

Re: update clicked node label and on demand json

ok nice. I stay tuned smile

Re: update clicked node label and on demand json

Any progress about this feature ?