Move selectedRow into view

4 posts, 0 answers
  1. Charles Goh
    Charles Goh avatar
    15 posts
    Member since:
    Nov 2004

    Posted 28 Feb 2013 Link to this post

    I used radGrid to display my items, also I am using javascript to find a row and select a row when user type in textbox. The problems is if those row is outside a radgrid's view, how can I move scrollBar to the selectedRow by javascript (clientside)
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 01 Mar 2013 Link to this post

    Hi,

    You can scroll to the selected item using the following javascript.
    JS:
    function GridCreated(sender, eventArgs) {
     var scrollArea = document.getElementById(sender.get_element().id + "_GridData");
           var row = sender.get_masterTableView().get_selectedItems()[0];
           if (row) {
               if ((row.get_element().offsetTop - scrollArea.scrollTop) + row.get_element().offsetHeight + 20 > scrollArea.offsetHeight) {
                   scrollArea.scrollTop = scrollArea.scrollTop + ((row.get_element().offsetTop - scrollArea.scrollTop) +
                   row.get_element().offsetHeight - scrollArea.offsetHeight) + row.get_element().offsetHeight;
               }
               else if ((row.get_element().offsetTop - scrollArea.scrollTop) < 0) {
                   scrollArea.scrollTop = row.get_element().offsetTop;
               }
           }
       }

    Thanks,
    Shinu
  3. Charles Goh
    Charles Goh avatar
    15 posts
    Member since:
    Nov 2004

    Posted 01 Mar 2013 Link to this post

    I tried that code but it is not working. Just please tell me what javascript function can move scrollbar? Thank you.
  4. Charles Goh
    Charles Goh avatar
    15 posts
    Member since:
    Nov 2004

    Posted 01 Mar 2013 Link to this post

    Hi Shinu,
    I have retried and success with some small changes with your code.Thank you.
Back to Top