PDA

View Full Version : [CLOSED] How to set checkbox node has been checked?



gs_user
Jun 21, 2012, 2:22 AM
Hi

This code is a loop to find the treenode and set checked was true
but checked node always false
How to resolve it??



protected void getsubnode(Ext.Net.Node subnode, string step)
{
foreach (Ext.Net.Node subnode1 in subnode.Children)
{
if (subnode1.Text.Split(' ')[0].ToString() == step)
subnode1.Checked = true;
if (subnode1.Children.Count > 0)
{
subnode1.Expanded = true;
getsubnode(subnode1, step);
}
}
mytree.render();
}

geoffrey.mcgill
Jun 21, 2012, 4:21 AM
Hi,

Is the first 'if' statement ever entered? This sample also only 'sets' the .Checked property. Nowhere in the sample does it 'get' the value of the .Checked property.

This sample does not do a good job of demonstrating the scenario. Please see the following tips for submitting a forum support request:

http://forums.ext.net/showthread.php?3440-Forum-Guidelines-For-Posting-New-Topics

http://forums.ext.net/showthread.php?10205-More-Information-Required

gs_user
Jun 21, 2012, 5:49 AM
When Button clicked, select data from db
I have to find the treenode, if the treenode text Equal col1 that treenode checked set true
I know the "node.checked = true" is set the checked box be checked
but in the code, is not avaliable




protected void buttonclick(object sender, DirectEventArgs e)
{
datatable flowtmp;
for (int k = 0; k < flowtmp.Rows.Count; k++)
{
foreach (Ext.Net.Node mynode in mytree.Root)
{
if (mynode.Children.Count > 0)
mynode.Children[0].Checked = true;

if (mynode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
mynode.Checked = true;
foreach (Ext.Net.Node subnode in mynode.Children)
{
if (subnode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
subnode.Checked = true;
if (subnode.Children.Count > 0)
{
getsubnode(subnode, flowtmp.Rows[k]["col1"].ToString());
}
}
}
}
mytree.Reload();

}

protected void getsubnode(Ext.Net.Node subnode, string step)
{
foreach (Ext.Net.Node subnode1 in subnode.Children)
{
if (subnode1.Text.Split(' ')[0].ToString() == step)
subnode1.Checked = true;
if (subnode1.Children.Count > 0)
{
subnode1.Expanded = true;
getsubnode(subnode1, step);
}
}
}

gs_user
Jun 21, 2012, 7:34 AM
I have another idear to add checknode

use code "mytree.CheckedNodes.Add(checkednode);"

checkedNodes.Add(SubmmitNode) type must be SubmittNode,

what's different between SubmittNode and TreeNode??

How to add CheckedNodes?



When Button clicked, select data from db
I have to find the treenode, if the treenode text Equal col1 that treenode checked set true
I know the "node.checked = true" is set the checked box be checked
but in the code, is not avaliable




protected void buttonclick(object sender, DirectEventArgs e)
{
datatable flowtmp;
for (int k = 0; k < flowtmp.Rows.Count; k++)
{
foreach (Ext.Net.Node mynode in mytree.Root)
{
if (mynode.Children.Count > 0)
mynode.Children[0].Checked = true;

if (mynode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
mynode.Checked = true;
foreach (Ext.Net.Node subnode in mynode.Children)
{
if (subnode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
subnode.Checked = true;
if (subnode.Children.Count > 0)
{
getsubnode(subnode, flowtmp.Rows[k]["col1"].ToString());
}
}
}
}
mytree.Reload();

}

protected void getsubnode(Ext.Net.Node subnode, string step)
{
foreach (Ext.Net.Node subnode1 in subnode.Children)
{
if (subnode1.Text.Split(' ')[0].ToString() == step)
subnode1.Checked = true;
if (subnode1.Children.Count > 0)
{
subnode1.Expanded = true;
getsubnode(subnode1, step);
}
}
}

gs_user
Jun 21, 2012, 8:40 AM
I find the reason to make checked equal true is not work.
I change the tree.render() position. It's can work now.




protected void buttonclick(object sender, DirectEventArgs e)
{
createtree_procedure(); --> I create a tree code behind ,end of the procedure, I set mytree.render().
I remove mytree.render code
datatable flowtmp;
for (int k = 0; k < flowtmp.Rows.Count; k++)
{
foreach (Ext.Net.Node mynode in mytree.Root)
{
if (mynode.Children.Count > 0)
mynode.Children[0].Checked = true;

if (mynode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
mynode.Checked = true;
foreach (Ext.Net.Node subnode in mynode.Children)
{
if (subnode.Text.Split(' ')[0].ToString() == flowtmp.Rows[k]["col1"].ToString())
subnode.Checked = true;
if (subnode.Children.Count > 0)
{
getsubnode(subnode, flowtmp.Rows[k]["col1"].ToString());
}
}
}
}
mytree.render(); --> I add tree render. It's can work now.

}

protected void getsubnode(Ext.Net.Node subnode, string step)
{
foreach (Ext.Net.Node subnode1 in subnode.Children)
{
if (subnode1.Text.Split(' ')[0].ToString() == step)
subnode1.Checked = true;
if (subnode1.Children.Count > 0)
{
subnode1.Expanded = true;
getsubnode(subnode1, step);
}
}
}