Dhtmlx-tree: submitting userdata to server on node childs (l

hello,



i’m playing with the tree component of the very great dhtmlx suite. i’m working with userdata to store information needed during the user’s work with the webapp. what i need and what i wasn’t able to get to work so far is submitting specific entries from the userdata of a node to the server when a node gets expanded and therefore the childs are loaded from the server → lacy loading.



i think about something like this:



dhxTree.setXMLAutoLoading(“loader.htm?cmd=fetchChilds&customData={userdata.myCustomData}”);



when a request is being made to the server the tree scripts could replace {userdata.myCustomData} with the actual user data “myCustomData” from the node that gets expanded. something like that… :wink:



is there any way to do that?



greez,



d. a. schaefer


Hello,


which tree edition do you use ?


The PRO provides setXMLAutoLoadingBehaviour method that allows to do following:


dhxTre.setXMLAutoLoadingBehaviour(“function”);


dhxTree.setXMLAutoLoading(function(id){


var value = dhxTree.getUserData(id,“some_userdata”);


dhxTree.loadXML(“loader.htm?cmd=fetchChilds&customData=”+value+"&id="+id);


});

hello,

i’m using the public, none commercial edition and allthough your suggestions looks fine, it is not usable unless some has the pro version. is there no option to do this with the none pro version?

greez,

d. a. schaefer


hello,


in case of standard edition you can try to use the following method that is based of internal property and not supported officially (so, it can be changed in the next tree versions):


tree.attachEvent(“onXLS”,function(tree,id){
var value = tree.getUserData(id,“some_userdata”);
tree.XMLsource = “loader.htm?cmd=fetchChilds&customData=”+value;
})




hello,

the idea is good but it does not work. it seems that the changed xmlSource is not beeing used but instead of it, the library allways uses the original one set through “tree.setXMLAutoLoading(“loader.htm?cmd=fetchChilds”);”. could it be that the problem occures because i’m using json as the datamodel.

tree.setDataMode(“json”);
tree.loadJSON(“loader.htm?cmd=fetchChilds”);

greez,

d. a. schaefer


yes, unfortunately in case of json loading the described approach can not be used.


You can try to modify loadJSON method, that is defined in the dhtmlxtree_json.js, according to your requirements:


dhtmlXTreeObject.prototype.loadJSON=function(file,afterCall){


var id = this._ld_id; /should be added/





this.XMLLoader.loadXML(file); /you can try to add the necessary parameters here/


}

hello,

first of all, thank you very much for your suggestion.
unfortunately i’m unable to do this kind of modification because:

    - the library downloaded from your side is some kind of compiled/bandwith optimised javascript.
    - due to your licence model i’m not allowed to do changes at the code.

maybe this it be something that could be chagned in the next release?
i ask because submitting user data is really essential for my usage scenario and i really like your tree implementation, not to say it’s the best i’ve found so far.


Probably the next tree version won’t contain modifications in this functionality.


Currently instead of previous suggestion you can create wrapper for loadJSON method as follows:


var a= tree.loadJSON;
tree.loadJSON=function(file,call){
var value = tree.getUserData(tree._id_id,“some_userdata”);
file = file+"&customData="+value;
return a.call(this,file,call);
};