I have a UltraTreeView inside an UpdatePanel set to UpdateMode=Conditional and a ScriptManager with AllowPartialUpdates="true" and have nodes being loaded with CheckBoxes and the treeview itself's LoadOnDemand is set to ManualSmartCallbacks.
Now, I have the treeview being loaded with it's subnodes and ajax calling back to get new nodes whenever one is expanded. Works like a champ.
The problem is that I need to get all the nodes that a user has checked. The problem is that in the code behind the if I being to transverse the treeview, all the "dynamically" loaded nodes aren't in the node list. I'm not surprised by this given the nature of AJAX.
However, I am trying to get the nodes via the igtree_getTreeById javascript. The problem is that is bringing back "undefined." I have made sure the name is correct and have even hardcoded by hand but still have no luck getting the igtree_getTreeById to pull back an object so I can grab some nodes from it.
Can anyone help me with igtree_getTreeById issue or show me a way to get all the checked CheckBoxes back from a treeview using AJAX?
Thanks again.
try like this:
var tree = igtree_getTreeById("<%= UltraWebTree1.ClientID %>");
UltraWebTree1 is the name of your tree.
Hello,
Indeed, this is correct - we need the client ID since the server ID will not always match the client-side one (this is an ASP.NET thing, controls nested in other controls INamingContainers like templates for example will have client IDs prepended to guarantee unique-ness).
So the approach suggested above is great. Another one is to capture the ID in the client-side InitializeTree event - the client ID is passed as a parameter there - and later it can be stored in a global variable. This is useful when you cannot directly reference your treeview in the ASPX template. Info on client-side events can be found here:
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR2.0/html/WebTree_Client_Side_Events_CSOM.html
Finally, I'd like to suggest the following forum thread for dealing with checkboxes on the client:
http://forums.infragistics.com/forums/p/3552/18718.aspx#18718
Hope this helps.
Yes. I already have tried <%=tvTreeview.ClientID %>, but it returns this error:
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
For this to work for me, I had to set a ClientSideEvent for the initializeTree (as someone posted above). I then set a global variable and assigned the global variable the treeId that is passed in. This worked perfectly.
When I did an alert, I realized that the tree is in a container (which I knew), but the function removes the "_"? That seemed to be the problem.
Thanks.
Sean
Yes, this could be the problem - if your server side ID has underscores "_" the <%# ServerID.ClientID %> approach will not work. Getting the client ID in client side InitializeTree event is the best approach (or you can replace "_" with "" on client, but that an ugly one)