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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

get GridDataControl sorted list

Thread ID:





92005 Dec 14,2009 08:42 AM UTC Oct 1,2013 08:03 AM UTC WPF 3
Tags: GridControl
Asked On December 14, 2009 08:42 AM UTC

I have a GridDataControl with few columns. I would like to retrieve the sorted list after clicking on the header.

To do that, I suscribe to SortColumns.CollectionChanged event and retrieve data from Model.View.Records but at this time, the list seems not be sorted yet.

Is there a way to do that ?

Thank you,

Ganesan K [Syncfusion]
Replied On December 14, 2009 04:31 PM UTC

Hi Thierry,

Thanks for using Syncfusion products.

You can achieve this by listen the MouseLeftButtonUp event like below.


dataGrid.MouseLeftButtonUp += new MouseButtonEventHandler(dataGrid_MouseLeftButtonUp);

void dataGrid_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
GridDataControl dataControl = sender as GridDataControl;
var rowColIndex = dataControl.Model.Grid.PointToCellRowColumnIndex(e.GetPosition(dataControl.Model.Grid));
var style = dataControl.Model[rowColIndex.RowIndex, rowColIndex.ColumnIndex];

if (style.CellType == "HeaderCell")
// Your custom code comes here.
var record = dataControl.Model.View.Records.First();
Orders order = record.Data as Orders;


Please let us know if you need any more details.


Replied On September 10, 2013 08:52 AM UTC

var record = this.grd_WatchList.Model.View.Records;

ObservableCollection <InstrumentEntry> sortedCollection = record as ObservableCollection<InstrumentEntry>;


In this code, although record has sorted data value, sortedCollection becomes null.

how can i do to get data value at sortedCollection


Thanks and Best Regards





Gobinath A [Syncfusion]
Replied On October 1, 2013 08:03 AM UTC

Hi Shwe,

Thanks for your update.

We have analyzed your query and you can get the sorted collection from the View by using the following code snippet

Code snippet[C#]:

this.syncgrid.Model.Table.SortColumnsChanged += new GridDataSortColumnsChangedEventHandler(Table_SortColumnsChanged);

void Table_SortColumnsChanged(object sender, GridDataSortColumnsChangedEventArgs args)


   this.Dispatcher.BeginInvoke(new Action(() =>


       var records = this.syncgrid.Model.View.Records;

       var SortedCollection = records as EnumerableRecordsWrapper;

       if (SortedCollection != null)


         // we can access the sorted record here.


      }), DispatcherPriority.ApplicationIdle);


Please let us know if you have any queries.


Gobinath A.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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