This is a migrated thread and some comments may be shown as answers.

RadTreeView Problem

3 Answers 64 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Deyan
Top achievements
Rank 1
Deyan asked on 08 Oct 2010, 09:14 AM

I have a treeview

1.<telerik:RadTreeView ID="RadTreeViewCombo" runat="server" DataFieldID="IdGroup" DataFieldParentID="IdParentGroup"
2.                    DataTextField="Name" DataValueField="IdGroup" OnDataBound="RadTreeViewCombo_DataBound"
3.                    DataSourceID="edsCosts" CheckBoxes="True" CheckChildNodes="True">
4.                    <DataBindings>
5.                        <telerik:RadTreeNodeBinding Depth="0" Expanded="false" />
6.                    </DataBindings>
7.                </telerik:RadTreeView>
and filter (textbox) that search all nodes by Text.

The problem is when a check node then filter by name (filter do only visible = false to unwanted nodes) 

then from result nodes I check some nodes after submiting (press button) the property CheckedNodes.Count=0 ?!?!?

If I do only filtering and then checking of result nodes or only checking without filtering there is no problem.

Search algorithm:

01.protected void btnSearch_Click(object sender, ImageClickEventArgs e)
02.    {
03.                SearchByName(RadTreeViewCombo.Nodes);
04.                RadTreeViewCombo.ExpandAllNodes();
05.    }
06.  
07.private void SearchByName(RadTreeNodeCollection radTreeNodeCollection)
08.    {
09.        foreach (RadTreeNode node in radTreeNodeCollection)
10.        { RecursiveSearhInNodes(node); }
11.  
12.    }
13.  
14.    private void RecursiveSearhInNodes(RadTreeNode node)
15.    {
16.        if (!node.Text.ToLower().Contains(txtSearch.Text.Trim().ToLower()))
17.        { node.Visible = false; }
18.        else
19.        { GoToParent(node.ParentNode); node.Visible = true; }
20.  
21.        foreach (RadTreeNode childNodes in node.Nodes)
22.        { RecursiveSearhInNodes(childNodes); }
23.    }
24.  
25.    private void GoToParent(RadTreeNode parentNode)
26.    {
27.        if (parentNode != null)
28.        {
29.            if (parentNode.ParentNode != null)
30.                GoToParent(parentNode.ParentNode);
31.  
32.            parentNode.Visible = true;
33.        }
34.    }

3 Answers, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 13 Oct 2010, 09:20 AM
Hello Deyan,

Are you inspecting the number of checked nodes on the client?
If this is the case, than probably the problem is caused by the fact, that the controls with set on the server Visible=false, are not rendered and they don't  have any client representation.

Hope this is helpful for you!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Deyan
Top achievements
Rank 1
answered on 18 Oct 2010, 01:07 PM

No its not on client side.

I just have usual button that on click call

1.protected void btnOk_Click(object sender, EventArgs e)
2.{
3.   string sChckedCosts = GetCheckedNodes();
4.}
01.public string GetCheckedNodes()
02.{
03.    StringBuilder sIds = new StringBuilder();
04.    StringBuilder sNames = new StringBuilder();
05.  
06.foreach (RadTreeNode nodeChecked in RadTreeViewCombo.CheckedNodes)
07.{
08.    sIds.Append(nodeChecked.Value + ",");
09.sNames.Append(nodeChecked.Text + ",");
10.}
11.  
12.return string.Format("{0}#{1}", sIds.ToString(), sNames.ToString());<br>
13.}
0
Nikolay Tsenkov
Telerik team
answered on 21 Oct 2010, 02:21 PM
Hi Deyan,

Well, I asked if you are checking them on the client, because the time is the significant variable here to be taken in account. So, after some search has hided the checked nodes on the server, then they were not rendered and serialized on the client. Therefore after the second post-back, their Checked state will be lost.

This, actually, is already logged as a bug in our issue tracking system and will be fixed.
For now you can hide the nodes on the client-side - on the server you can mark them by adding a custom css class to them and on the client to style all elements in possession of this class to be with "display:none".
You should not be using "visability:hidden", because the nodes will be rendered as a blank spot taking the size they would usually get if visible.

Sorry for the caused inconvenience!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
Deyan
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Deyan
Top achievements
Rank 1
Share this question
or