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

[Solved] AutoFocus on Searched Keyword

12 Answers 179 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Coldapoy
Top achievements
Rank 2
Coldapoy asked on 25 Jul 2008, 08:32 AM
"AutoFocus on Searched Keyword"

hi again, done a work around on other problems i had with treeview.. thanks to the moderators..

i have another question... if ever i search for a keyword and then if it is in the treeview autofocus will occur..

can you help me with this?

if statement  i guess? or what do you suggest?

TIA

12 Answers, 1 is accepted

Sort by
0
Coldapoy
Top achievements
Rank 2
answered on 25 Jul 2008, 12:12 PM
function FindNode()
{
   var tree= $find("<%= RadTreeView1.ClientID %>");
   var node
= tree.findNodeByText("Child RadTreeNode 1");
   
//... or ...
   
var node1 = tree.findNodeByValue("3");
   
//... or ...
   
var node2 = tree.findNodeByAttribute("MyCustomAttribute", "Some Value");
   node.get_parent().expand();
   node.select();
}


using this how can i compare the input of a user in a textbox to it?
0
Veselin Vasilev
Telerik team
answered on 25 Jul 2008, 02:18 PM
Hello Coldapoy,

I am afraid I cannot completely understand your task. Would you please elaborate a bit more on what exactly you are up to?

Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Coldapoy
Top achievements
Rank 2
answered on 26 Jul 2008, 05:34 AM
sure its like this...

in my rad treeview displays the hierarchy on my authority table..
and then.... there is a search textfield for my authorities and as the user clicks on search my treeview will only display all its parents and children and of course the searched authority as well.
i'm done with that...

now. i want to focus the searched authority being searched for example if authority2 is searched in the treeview there is i think a highlight as soon as the treeview search loads.

hope this time its clear....
0
Coldapoy
Top achievements
Rank 2
answered on 27 Jul 2008, 02:34 AM
is it possible to use .highlight() for it too? after i compare the node searched?
0
Coldapoy
Top achievements
Rank 2
answered on 29 Jul 2008, 02:59 AM
anyone?
0
Veselin Vasilev
Telerik team
answered on 29 Jul 2008, 07:53 AM
Hello Coldapoy,

Yes, you can use the highlight() method of RadTreeNode class.

You can get the text typed in a textbox in the following way:

var text = $get("TextBox1").value

then you can search among the tree nodes:

var node = tree.findNodeByText(text);
node.
highlight();


Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Coldapoy
Top achievements
Rank 2
answered on 29 Jul 2008, 08:23 AM
javascript on my ascx

function highlightNode()
            {
       var atv = document.getElementById("<%=this._uscRadTrvSelectAuthority.ClientID %>");
       var text = $get("<%=this._uscTxtSearch.ClientID %>").value
       var node = atv.findNodeByText(text);
       node.highlight();
            }

and at my server side

this._uscBtnSearch.Attributes.Add("onClick", "highlightNode();");

its not working and it was giving me some errors on my second search?
where did i get wrong?

my target is that when i click on search when the value of the textbox match with the any node on the treeview it is automatically highlighted like when we click on the node.

0
Coldapoy
Top achievements
Rank 2
answered on 29 Jul 2008, 09:23 AM
also triend afterClientClick="javascript:return highlightNode()"

btw, i'm using Q1 2008

really need this badly... this is my last function for my telerik rad treeview..
0
Coldapoy
Top achievements
Rank 2
answered on 30 Jul 2008, 07:24 AM
i got no reply....

hmm...

btw got the answer to my question.. used ".select();"

0
Veselin Vasilev
Telerik team
answered on 30 Jul 2008, 01:47 PM
Hello Coldapoy,

Looking at your account information I cannot see which versions of our controls you have downloaded. Can you please let me know so we can better support you?

You posted your question to the RadTreeView for ASP.NET AJAX forum, but you are using the AfterClientClick property which is part of the RadTreeView "classic".

You need to get a proper reference to the RadTreeView client object. This is done in the following ways:
  • RadTreeView for ASP.NET ("classic")
var tree = <%= RadTreeView1.ClientID %>;
  • RadTreeView for ASP.NET AJAX
var tree = $find("<%= RadTreeView1.ClientID %>");

The counterpart of the AfterClientClick property is OnClientNodeClicked.

You can observe our online documentation starting from here: Client-Side Programming Basics

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Coldapoy
Top achievements
Rank 2
answered on 16 Jan 2009, 03:01 AM
just wondering... is there a way for this from the code behind? tried .select = true; but is just selects the node and highlights it but the treeview did not autho focus to it.

as for the client side it works... .select()
0
Manoj
Top achievements
Rank 1
answered on 22 Jan 2009, 01:57 PM
Hi Coldapoy,
    Try this.

foreach

(RadTreeNode node in rtvDetailData.GetAllNodes())

 

{

 

    if (node.Text.Contains(txtSearch.Text))

 

    {

        node.ForeColor =

Color.Blue;

 

    }

 

    else

 

    {

        node.ForeColor =

Color.Black;

 

    }

}

With Regards
Manoj

Tags
TreeView
Asked by
Coldapoy
Top achievements
Rank 2
Answers by
Coldapoy
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Manoj
Top achievements
Rank 1
Share this question
or