Groups collapsed when sorting

Hi,

I have two questions:

1) Is there a way to disable the collapsing of the groups when a user clicks on a column to sort on that column?
2) Is there an event thrown when the user clicks on the header of a column to sort the column? (OnSorting / OnSorted )

Thanks.

1 Reply

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);
}



Loader.
Up arrow icon