FindByTextCommand

9 posts, 0 answers
  1. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 07 Feb 2010 Link to this post

    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
  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 08 Feb 2010 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 08 Feb 2010 Link to this post

    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
  5. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 10 Feb 2010 Link to this post

    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.
  6. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 10 Feb 2010 Link to this post

    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];

     

  7. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 12 Feb 2010 Link to this post

    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.
  8. Claude
    Claude avatar
    63 posts
    Member since:
    Apr 2009

    Posted 12 Feb 2010 Link to this post

    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?
  9. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 15 Feb 2010 Link to this post

    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.
  10. Stefan
    Admin
    Stefan avatar
    2891 posts

    Posted 22 Mar 2011 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready