![GridControl 分组排序 GridControl 分组排序](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
方法一:纯代码
this.list.gridControl.ItemsSource = lsItem; this.list.gridControl.GroupBy("GroupTitle");
this.list.gridControl.Columns["GroupTitle"].SortOrder = ColumnSortOrder.Descending;
//this.list.gridControl.SortBy(this.list.gridControl.Columns["GroupTitle"], ColumnSortOrder.Descending); this.list.gridControl.ExpandAllGroups();
方法二:XAML定义,构造函数中绑定
实时分组(先取消之前的分组)
private void ListGrouping(string strType)
{
if (string.IsNullOrEmpty(strType)) return; if (strType == "Room")
{
//ColumnView.SortInfo
this.list.gridControl.SortInfo.Clear();//clear grouping
this.list.gridControl.GroupBy("RoomName");
this.list.gridControl.Columns["RoomName"].SortOrder = ColumnSortOrder.Ascending; this.list.gridControl.ExpandAllGroups(); }
else if (strType == "Status")
{
this.list.gridControl.SortInfo.Clear();//Clear grouping
this.list.gridControl.GroupBy("Status");
this.list.gridControl.Columns["Status"].SortOrder = ColumnSortOrder.Ascending; this.list.gridControl.ExpandAllGroups();
} }