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

Selected row after sorting on initial databind

1 Answer 216 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Developer Developer
Top achievements
Rank 1
Developer Developer asked on 31 Mar 2010, 02:59 PM
When I add a sort expression the grid appears to behave as follows during the initial databind:

  • First row is selected
  • Grid data is sorted
  • GridView scrolls it's content down to the row that was selected (which used to be the first row, but after sorting, is now at the bottom of the grid)

The desired behavior is to have the first row selected after sorting (instead of scrolling down to the previously selected row).  Does anyone know how to do this?

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 06 Apr 2010, 09:39 AM
Hi,

You can handle the SortChanged event of RadGridView to support this behavior:
 

void radGridView1_SortChanged(object sender, GridViewCollectionChangedEventArgs e)
{
    if (this.radGridView1.Rows.Count > 0 && this.radGridView1.CurrentRow != this.radGridView1.Rows[0])
    {
        this.radGridView1.CurrentRow = this.radGridView1.Rows[0];
    }
}

 
Greetings, Julian Benkov
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
Developer Developer
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or