Categories | Question details Back To List | ||
Last item in tree not checked Hello, I'd to like to set the check boxes of the country tree back to what it was before the user submitted a form and presses the back button. The javascript function that is called manages this for every country, except for the last one in the list. I've built in some alerts to see the output and the setCheck for the last country is being performed, but the alert with "is id checked" then returns undefined. If I add another node (by checking its checkbox) after the last checked node, then this new node is not checked when returning after submission. The country's abbreviation is unique and used as ID of the tree. Here's the javascript code of the function that sets the checkboxes: function updatecountrycheckednodes(request) { if (request.readyState == 4) { if (request.status == 200) { var selection = request.responseText; if (selection != null && selection != "" && selection != "\n" && selection != "\r\n") { alert (selection); var countries = selection.split(","); var firstId = ""; for (var i = 0; i < countries.length; i++) { var id = countries[i]; alert("countries[" + i + "] = " + countries[i]); if (id != "") { if (firstId == "") firstId = id; ctree.setCheck(id,1); alert("is id " + id + " checked: " + ctree.isItemChecked(id)); } } if (firstId != "") ctree.focusItem(firstId); } } else { alert('There was a problem with the request.'); } } return true; } Regards, Theo Answer posted by Alex (support) on Feb 16, 2009 06:16 Hello, isItemChecked returns undefied when there is not an item with defined id in a tree. Please, check that the item exists. If problem is not resolved, please provide the sample where it can be reproduced (code of tree initialization, tree xml and list of ids). Answer posted by theo on Feb 16, 2009 06:18 Thanks for your answer. I already found out that the response always contains a linefeed at the end, and that was part of the id I was trying to set the checkbox with. Cheers, Theo |