get GridDataControl sorted list
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,
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
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
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.
- 3 Replies
- 4 Participants
-
TR Thierry ROLLAND
- Dec 14, 2009 08:42 AM UTC
- Oct 1, 2013 08:03 AM UTC