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

FindByTextCommand

8 Answers 43 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Claude asked on 08 Feb 2010, 04:12 AM
I have a treeview and after adding a node, I want to select that node.  The tree is databound.   I am trying to implement the FindByTextCommand, but am having troubles.  Can you supply sample code on the implementation. 

Thanks

8 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 08 Feb 2010, 08:35 AM
Hello Claude,

Thank you for writing. Please explain what kind of issues are you having? Commands are documented in our online documentation. I am looking forward to your reply.

Greetings,
Victor
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Claude
Top achievements
Rank 1
answered on 08 Feb 2010, 01:50 PM
Here is the code per documentation

Telerik.WinControls.Commands.

FindByTextCommand cmd = new FindByTextCommand();

 

 

 

List<object> result = RadTreeView.ExecuteBatchCommand(this.radTreeView1.Nodes, -1, cmd, "bbbb");

 

 

if (result != null)

 

{

 

MessageBox.Show("lll");

 

}



No matter what I use for the search text the result is always !null.  Also, what does result bring back to me?  Node index or what?  Not sure what to put in the {   }. 

thanks
0
Victor
Telerik team
answered on 10 Feb 2010, 12:05 PM
Hi Claude,

Thank you for writing. As you can see from the code the result is of type List<object>. When RadTreeView returns a result, the real type will be RadTreeNode which means you will have to do an explicit type cast. FindByTextCommand() (as the name suggests) searches for nodes with a specific value in the nodes Text properties.

I have attached a sample application which demonstrates FindByTextCommand. Please write again if you have more questions about our controls.

Sincerely yours,
Victor
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Claude
Top achievements
Rank 1
answered on 10 Feb 2010, 10:12 PM
The example works fine.  The treeview I have is Data Bound and this does not seem to work.    

My code for building the tree is below.   All loads fine.  However when I implement the FindByTextCommand, I can not find any nodes on any layer.  My intent is when I add a new node into the db and rebuild the tree, i want to find that node and selsct it.

 

// fill table adapters

 

 

this.dbo_custTableAdapter1.Fill(this.pDAgentDataSet._dbo_cust);

 

 

this.dbo_pltTableAdapter1.Fill(this.pDAgentDataSet._dbo_plt);

 

 

this.dbo_equipTableAdapter1.Fill(this.pDAgentDataSet._dbo_equip);

 

 

this.dbo_voltTableAdapter1.Fill(this.pDAgentDataSet._dbo_volt);

 

 

this.dco_eqTypeTableAdapter1.Fill(this.pDAgentDataSet._dco_eqType);

 

 

 

 

// set up treeview

 

 

this.radTreeView1.RelationBindings.Add(new RelationBinding("CustPlt", custPltBindingSource));

 

 

this.radTreeView1.RelationBindings.Add(new RelationBinding("PltEquip", pltEquipBindingSource));

 

 

this.radTreeView1.RootRelationDisplayName = "Clients";

 

 

this.radTreeView1.DataSource = this.dbocustBindingSource;

 

 

this.radTreeView1.ExpandLevel(0);

 

 

this.radTreeView1.SelectedNode = radTreeView1.Nodes[0].Nodes[0];

 

0
Victor
Telerik team
answered on 12 Feb 2010, 01:05 PM
Hello Claude,

FindByTextCommand is not influenced by the data binding in RadTreeView. Whenever you have nodes in your tree view, the command will search them. Please have a closer look at your code, there may be something that you are missing. Is your treeview handle created? Does your tree view have any nodes when you are executing the command? Write again if you have other questions.

Kind regards,
Victor
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
Claude
Top achievements
Rank 1
answered on 12 Feb 2010, 07:48 PM
I figured out my problem.  The db has data type as char(50), which pads with white space.  I was searching for text using Trim().   Therefore no match. 

One quick question.  In the foreach loop of he result, how can I select the found node?
0
Victor
Telerik team
answered on 15 Feb 2010, 09:18 AM
Hello Claude,

You can set the node to be selected by using SelectedNode property of RadTreeView. For example:

foreach (object node in result)
{
    RadTreeNode converted = (RadTreeNode)node;
     
    if( /* Some condition to determine if this is the node you are looking for,
         * since there maybe multiple nodes with the same text. */)
    {
        this.treeView.SelectedNode = converted;
    }
}

Please write again if you have other questions.

Greetings,
Victor
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
Stefan
Telerik team
answered on 22 Mar 2011, 04:45 PM
Hello Claude,

Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.

All the best,
Stefan
the Telerik team
Tags
Treeview
Asked by
Claude
Top achievements
Rank 1
Answers by
Victor
Telerik team
Claude
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or