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

ScrollIntoView

5 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Phillip Garrett
Top achievements
Rank 1
Phillip Garrett asked on 18 Jun 2010, 09:27 AM

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

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 18 Jun 2010, 09:54 AM
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
0
Phillip Garrett
Top achievements
Rank 1
answered on 18 Jun 2010, 09:57 AM
Please can you show me the ugly hack :)
Thanks,
Phill
0
Pavel Pavlov
Telerik team
answered on 18 Jun 2010, 01:29 PM
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
0
Marc Roussel
Top achievements
Rank 2
answered on 06 Oct 2010, 07:23 PM

How would you convert this

rgvJobs.SelectedItem = Job;

rgvJobs.ScrollIntoView(Job);

Into this :

rgvJobs.ScrollIntoViewAsync(Job, f =>

{

 

 

    // What do I put here ?

 

});

0
Veselin Vasilev
Telerik team
answered on 07 Oct 2010, 03:38 PM
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
Tags
GridView
Asked by
Phillip Garrett
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Phillip Garrett
Top achievements
Rank 1
Marc Roussel
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Share this question
or