Get checked node on server side

Hi,



I am displaying a dhtmlxTree on my View and want all those nodes that have been checked on the server side at the click of submit button.

I trying to figure this out but unable to do it. No matter whatever item i check or uncheck i do not get anything on server at submit click.



Thanks,

Huzefa


Hello,


tree checkboxes are images. So, they are not submitted automatically.


You can use getAllChecked method to get list with ids of checked items:


var ids = tree.getAllChecked()

Hi…

I’ve got the same problem…

My tree is nested in a form in that div :

And called by this pice of script :

I tried many methods you gave on this forum (serialisation…) but I can’t make it work… I can’t get checkbox id’s in the page called by my form… I just want to send checkbox id’s in the form…

Thanks

M

Hi

you can place an addition input for checked ids inside a form (hidden input). Method getAllChecked returns list with ids of checked items:

tree.attachEvent(“onCheck”,function(){

var list = tree.getAllChecked();

document.getElementById(“inputId”).value = list;

})

Thanks Alexandra… You saved my life !!
Do you want to marry me ?

Don’t know if I should create a new subject… I supposed you understood in my last message the trick you gave me did it great.

I adaptated it to get the selected element as well… here is the code

tree.attachEvent("onCheck",function(){
	var list = tree.getAllChecked();
	document.getElementById("entitiesId").value = list;})
tree.enableHighlighting(true);
tree.attachEvent("onClick",function(){
	var list = tree.getSelectedItemId();
	document.getElementById("entitiesMainId").value = list;})

It works flowlessly but I’m not able to reselect an element on tree load. The setCheck method works but do you have a kind of setSelect Method ?

Thanks !

You can use selectItem method:

tree.selectItem(id)