ScrollIntoView after server code

5 posts, 0 answers
  1. Quim
    Quim avatar
    29 posts
    Member since:
    Nov 2006

    Posted 23 Oct 2008 Link to this post

    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

  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 24 Oct 2008 Link to this post

    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.
  3. Quim
    Quim avatar
    29 posts
    Member since:
    Nov 2006

    Posted 28 Oct 2008 Link to this post

    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
  4. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 31 Oct 2008 Link to this post

    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.
  5. Quim
    Quim avatar
    29 posts
    Member since:
    Nov 2006

    Posted 07 Nov 2008 Link to this post

    Hi

    I think problem 1) is solved after installing Q3 2008

    Regards
    Quim
Back to Top