GridControl 分组排序

时间:2023-03-10 05:21:43
GridControl 分组排序

方法一:纯代码

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定义,构造函数中绑定

GridControl 分组排序

GridControl 分组排序

实时分组(先取消之前的分组)

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