ScrollIntoView

6 posts, 0 answers
  1. Phillip Garrett
    Phillip Garrett avatar
    25 posts
    Member since:
    Apr 2010

    Posted 18 Jun 2010 Link to this post

    Hi,

    Using ScrollIntoView with SelectedItem always places the selected row at the bottom of the visible grid. Is there a way to have the SelectedItem appear at the top of the visible grid after scrolling into view?

    Thanks,

    Phill

  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Jun 2010 Link to this post

    Hello Phillip Garrett,

    This is the default behavior of RadGridView by design . Still it is possible to achieve what you request , but it will involve some pretty  ugly hacks . Let me know in case you decide to go that way and I will try to prepare a small sample for you.

    All the best,
    Pavel Pavlov
    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
  3. DevCraft banner
  4. Phillip Garrett
    Phillip Garrett avatar
    25 posts
    Member since:
    Apr 2010

    Posted 18 Jun 2010 Link to this post

    Please can you show me the ugly hack :)
    Thanks,
    Phill
  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 18 Jun 2010 Link to this post

    Hi Phillip Garrett,

    Here you are:

    private void ScrollItemToTop(int itemIndex)
            {
                this.RadGridView1.ScrollIntoViewAsync(this.RadGridView1.Items[RadGridView1.Items.Count - 1],
                            f =>
                            {
                                this.RadGridView1.ScrollIntoView(this.RadGridView1.Items[itemIndex]);
                            }
      
                            );
            }

    This method will scroll the Item intto view and place it on the top.

    The hack is based on the fact that if the Item comes from above the view port is always placed at the top . So what we actually do is - first scroll to the end , then scroll to the item .
    The result - the item finally is on top.

    Best wishes,
    Pavel Pavlov
    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
  6. Marc Roussel
    Marc Roussel avatar
    429 posts
    Member since:
    Dec 2009

    Posted 06 Oct 2010 Link to this post

    How would you convert this

    rgvJobs.SelectedItem = Job;

    rgvJobs.ScrollIntoView(Job);

    Into this :

    rgvJobs.ScrollIntoViewAsync(Job, f =>

    {

     

     

        // What do I put here ?

     

    });

  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 07 Oct 2010 Link to this post

    Hi Marc Roussel,

    This should work:

    rgvJobs.ScrollIntoViewAsync(Job, f =>
    {
       rgvjobs.ScrollIntoView(Job);
     
    });


    Regards,
    Veselin Vasilev
    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
Back to Top
DevCraft banner