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.

saving the sort

Thread ID:

Created:

Updated:

Platform:

Replies:

60590 May 8,2007 01:44 PM May 9,2007 04:13 PM Windows Forms 4
loading
Tags: GridControl
Charlie Mao
Asked On May 8, 2007 01:44 PM

Hi,

I was wondering if there is a way to grab the way a grid has been sorted. Currently, when i clear out the grid using grid.GridBoundColumns.Clear(); the sort also gets cleared out. Can I grab how the grid is sorted, clear out the grid, and redraw the new grid with the same sort?

Thanks,
Charlie

Saravanan A [Syncfusion]
Replied On May 8, 2007 03:11 PM

Hi Charlie,

Please refer to the following forum threads that will help you to get the sorted order.

http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=36183
See the last thread in this forum.http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=12261

Using these information you can reapply the same sorting, programmatically after changing the datasource.
Here is the code snippet to apply sorting programmatically.

CurrencyManager cm = this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource,
this.gridDataBoundGrid1.DataMember] as CurrencyManager;
if(cm != null)
{
int colIndex = this.gridDataBoundGrid1.Binder.ColIndexToField(2);
string colName = this.gridDataBoundGrid1.Binder.InternalColumns[colIndex].MappingName;

DataView dv = cm.List as DataView;
dv.Sort = string.Format("[{0}] DESC", colName);
}
}

Best Regards,
Saravanan

Charlie Mao
Replied On May 8, 2007 04:01 PM

Hi Saravanan,

Thanks for the reply. This code snippets seems to apply the sort programmatically for the second column descending. What if the user changes the sort to another column, can you catch that change and apply it programmatically.

Charlie

Saravanan A [Syncfusion]
Replied On May 8, 2007 09:14 PM

Hi Charlie,

Please refer to the following sample, in which the sorting order is retained while reinitializing the datasource.

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

Best Regards,
Saravanan

Charlie Mao
Replied On May 9, 2007 04:13 PM

Hi Saravanan,

Thank you so much. This worked great.

Charlie

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.

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.

;