We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Databound Grid Column Sorting

Thread ID:

Created:

Updated:

Platform:

Replies:

1489 Nov 4,2002 03:23 PM UTC Nov 4,2002 05:41 PM UTC Windows Forms 1
loading
Tags: GridControl
Anthony Mansfield
Asked On November 4, 2002 03:23 PM UTC

Is there a way to determine which column is currently sorted and if it is sorted ascending/descending? I have a databound grid that is refreshed based on other form events. Each time the grids datasourece is updated I am calling the ColumnSort(1) to ensure that the grid is sorted. This is causing the grid to toggle between an ascending and descending sort, even though the data has been refreshed. I thought about checking to see if it is currently sorted and then only sorting if needed, but I could not find a way to determine if it was sorted. Should the sort be maintained, even though the datasource has changed? Thanks - Anthony

Stefan Hoenig [Syncfusion]
Replied On November 4, 2002 05:41 PM UTC

Hi Anthony, the following methods should let you do all the sorting directly on the underlying datasource: public static ListSortDirection GetSortDirection(IList list) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) return ((IBindingList)list).SortDirection; return ListSortDirection.Ascending; } public static PropertyDescriptor GetSortProperty(IList list) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) return ((IBindingList)list).SortProperty; return null; } public static void SetSort(IList list, PropertyDescriptor property, ListSortDirection sortDirection) { if (list is IBindingList && ((IBindingList)list).SupportsSorting) ((IBindingList)list).ApplySort(property, sortDirection); } public static bool SupportsSort(IList list) { return list is IBindingList && ((IBindingList)list).SupportsSorting; } I'll make a note that the Sort method in the GridModelDataBinder should accept a SortDirection. Stefan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;