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. Image for the cookie policy date
close icon

Regarding column header click sort

Hi All,

I am using GridGroupingControl, while click on grid Column header it's sorting properly and showing on the UI but problem is after sort in UI, In the datasource BindingList doesn't contain sorted list it contain old list only(which was assigned initailly before sort in UI. So it means that sort in column header click doesn't sort in underlying datasource.

Can you give please tell me how do i update underlaying datasource while sorting in UI?

Waiting for your reply...

Thanks and Regards
K.Sathishkumar


1 Reply

AD Administrator Syncfusion Team March 13, 2008 11:24 AM UTC

Hi Sathishkumar,

Thank you for your interest in Syncfusion products.

To sort the underlaying datasource while sorting in UI to handle TableControlQueryAllowSortColumn and set the ApplySort method.
Please refer the code below for more details.

void TableControl_QueryAllowSortColumn(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridQueryAllowSortColumnEventArgs e)
{
CurrencyManager lm = this.BindingContext[this.gridGroupingControl1.DataSource] as CurrencyManager;
ListSortDirection direction=((IBindingList)lm.List).SortDirection;
if (direction == ListSortDirection.Ascending)
direction = ListSortDirection.Descending;
else
direction = ListSortDirection.Ascending;

if (lm.List is IBindingList && ((IBindingList)lm.List).SupportsSorting)
{
PropertyDescriptorCollection pdc = lm.GetItemProperties();
((IBindingList)lm.List).ApplySort(pdc[0], direction);
}
Console.WriteLine(((IBindingList)lm.List).SortDirection.ToString());
}


Please refer the attached sample for more details.

http://websamples.syncfusion.com/samples/Grid.Windows/I41988/main.htm

Best Regards,
Asem.



Loader.
Live Chat Icon For mobile
Up arrow icon