CB
Clay Burch
Syncfusion Team
September 18, 2009 02:33 PM UTC
1) Currently, there is no property setting that will prevent losing your groups on a Sort.
2) You can catch the "OnSorted" action by listening to the grid.Model.TableProperties.SortColumns.CollectionChanged event. You can catch the "OnSorting" using a preview mouse down event.
public Window1()
{
InitializeComponent();
//subscribe to the events after the Model has been loaded...
dataGrid.ModelLoaded += (s, e) =>
{
dataGrid.PreviewMouseDown += new MouseButtonEventHandler(dataGrid_PreviewMouseDown);
dataGrid.Model.TableProperties.SortColumns.CollectionChanged += new NotifyCollectionChangedEventHandler(SortColumns_CollectionChanged);
};
}
void dataGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
RowColumnIndex cell = dataGrid.Model.Views.First().PointToCellRowColumnIndex(e.GetPosition(dataGrid));
if (cell.RowIndex == dataGrid.Model.HeaderRows + 1)
{
Console.WriteLine("Sorting column {0} {1}", cell.ColumnIndex, dataGrid.VisibleColumns[cell.ColumnIndex].MappingName);
}
}
void SortColumns_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Console.WriteLine("Sorted Action= {0}", e.Action);
}