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.

get GridDataControl sorted list

Thread ID:

Created:

Updated:

Platform:

Replies:

92005 Dec 14,2009 03:42 AM Oct 1,2013 04:03 AM WPF 3
loading
Tags: GridControl
Thierry ROLLAND
Asked On December 14, 2009 03:42 AM

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 11:31 AM

Hi Thierry,

Thanks for using Syncfusion products.

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

[C#]

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.

Thanks
Ganesan

Shwe
Replied On September 10, 2013 04:52 AM

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

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

Hi,

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 04:03 AM

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.

Regards,

Gobinath A.

 


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.

;