Hi,
I need to loop through the WebDataTree in JavaScript and get a list of all "selected" checkboxes. I tried the below code. But it works only for the first entry in the loop.
for (var i=0; i < len; i++)
{
var node = nodes.getNode(i);
m_strResult = m_strResult + node.get_text();
var objChkBox = node._checkBox;
m_strResult = m_strResult + " : " + node.get_selected() + "\n";
}
Here objChkBox is null from the second node in the tree.
Also from the objChkBox object how do I know if the checkbox is selected?
Please let me know what I am missing.
Thanks
Prasad
you can get all the checked nodes in the tree by calling tree.get_checkedNodes(). It will return an array of $IG.Node objects.Then on each node you can call node.get_checkState() which can return 0-Unchecked, 1-Checked, 2-Partial depending on the check box mode you have configured.
Hope this helps.
Thanks,
Lubomir
I´m using tree.CheckedNodes (in C# ) and it works just fine.
Never the less i was wondering if it is possible to get only all checked nodes of a certain level? For example, get all checked nodes in level 2.
And one other question, is it possible to have checkboxes only in level 2 and NOT on level 0 and level 1?
Thanks in advance,
Samuel Jesus
Lubomir,
What might I be missing here?
I'm assuming that you're working the "tree.get_checkedNodes()" in JavaScript. But when I use it, I get an "Object doesn't support this property of method" JScript runtime error.
Pertinent parts of my code:
<ig:webdatatree ID="tvwUserGroups" runat="server" InitialExpandDepth="2" EnableExpandOnClick="true" InitialDataBindDepth="2" EnableSingleBranchExpand="true" EnableConnectorLines="true" AutoPostBackFlags-NodeClick="on" CheckBoxMode="BiState" DataLoadingMessage="Loading...Please be patient" ViewStateMode="Enabled">
<DataBindings><ig:datatreenodebinding DataMember="dtGroups" TextField="Name" ValueField="Guid" /> </DataBindings>
</ig:webdatatree>
BLOCKED SCRIPT
function GetUserGroups() {
var nodes = new Array;
var tree = document.getElementById('<%= tvwUserGroups.ClientID %>');
nodes = tree.get_checkedNodes();
var userGroupGuid = "";
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].get_checkState == 1) {
if (userGroupGuid.length > 0) {
userGroupGuid += "|";
userGroupGuid += nodes[i].value;
document.getElementById('<%= hdnUserGroupList.ClientID %>').value = userGroupGuid'
} // end function
The point of this whole exercise is that I have a tree of Active Directory Groups and the Users who belong to those groups. The user can select one or more Groups and/or Users by checking the appropriate checkboxes, then clicking an "Assign" button. The Idea is to walk the tree and collect the checked nodes so that those Groups and Users can be granted access to the assigned stuff.
I tried walking the tree on the server side, but none of the nodes showed up as checked. I figure now I need to collect the data on the client side and pass it to the server with a Hidden Control.
Any other thoughts would be much appreciated.
Michell
Thanks, This worked for me.