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

How to jump to the first page when a column is sorted

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Herman Gouw
Top achievements
Rank 2
Herman Gouw asked on 03 May 2011, 03:00 AM
In my current project, I have a RadGrid with Paging and Sorting enabled.

The screenshot of the RadGrid is available on http://imageshack.us/f/848/dataaccessradgrid.jpg

When a column is sorted or unsorted, I would like the RadGrid to jump to the first page of the RadGrid.

Can you please show me how to do this?

Thanks,
Herman

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 03 May 2011, 02:58 PM
Hi Herman,

You can handle the SortCommand server-side event of the grid and change the current page index. Here is an example how to achieve this functionality:

Aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" PageSize="5" AllowPaging="true" AllowSorting="true" OnNeedDataSource="RadGrid1_NeedDataSource" OnSortCommand="RadGrid1_SortCommand">
</telerik:RadGrid>
C#:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
  (sender as RadGrid).DataSource = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
}
protected void RadGrid1_SortCommand(object sender, GridSortCommandEventArgs e)
{
  (sender as RadGrid).CurrentPageIndex = 0;
}

All the best,
Vasil
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Herman Gouw
Top achievements
Rank 2
Answers by
Vasil
Telerik team
Share this question
or