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
>
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.
}