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

ScrollIntoView after server code

4 Answers 91 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Quim
Top achievements
Rank 1
Quim asked on 23 Oct 2008, 04:46 PM
Hi

I have two situations with treeview:

1) I have a textbox where I enter an ID to search in a treeview. Sometimes, the textbox loses focus and I cannot insert nothing any more. The textbox is in the same window with treeview.

2) I have a searching operation using server code to  find and select the node I'm looking for. After that, server code calls a Javascript function to load detailed information in another window. This is working ok, however, I need to guarantee that selected node is visible and not outside of my window. It seems that "scrollIntoView" is the solution to this.
I try to add this code:

  var tree = $find("<%= RadTreeView1.ClientID %>");
  if (tree.get_selectedNode() != null)
  {
       tree.get_selectedNode().scrollIntoView();
   }

but I got an error: 'null' is null or not an object.
I'm calling my javascript function using scriptmanager.RegisterClientScriptBlock

Regards

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 24 Oct 2008, 02:44 PM
Hi Quim,

1. Are you using a standard asp.net textbox or RadTextBox? What are the steps to reproduce the problem?

2. Maybe the treeview is not yet initialized on the page when that script is executed. Please place the script in the pageLoad() method (this guarantees that all controls are initialized).

Regards,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Quim
Top achievements
Rank 1
answered on 28 Oct 2008, 10:03 AM
Hi

1) This already happened with both. My treeview loads on demand from an XML file. It seems that this only happens when using RadAjaxManager. Because Treeview is load on demand, I defined treeview to initiate a Ajax Request and also to be updated by respective Ajax. Removing this Ajax selection seems to stop this problem (need more tests to guarantee) . I saw in Q3 2008 that there is a fix to Treeview that in same conditions could take focus from these controls. Could this be related?

2) Clicking search button I'm using RadAjaxManager to update treeview, how do I put this function on server page_load() event? I don't detect any postback after node selection (even removing RadAjaxManager configuration).

Regards
0
Veselin Vasilev
Telerik team
answered on 31 Oct 2008, 01:17 PM
Hi Quim,

1. When the treeview is using serversidecallback load-on-demand - you do not need to use RadAjaxManager - the treeview will make ajax callbacks automatically to the server and the page will not refresh.

2. I meant the client-side pageLoad() method. The function with this name will be executed right after the Sys.Application.load event and this guarantees that all the scripts have been loaded and the objects have been created and initialized. More information is available here and here.


Best wishes,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Quim
Top achievements
Rank 1
answered on 07 Nov 2008, 06:11 PM
Hi

I think problem 1) is solved after installing Q3 2008

Regards
Quim
Tags
TreeView
Asked by
Quim
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Quim
Top achievements
Rank 1
Share this question
or