コード例 #1
0
        /// <summary>
        /// 按照自定义排序规则排序
        /// </summary>
        /// <param name="colName">待排序字段</param>
        /// <param name="sortCommand">排序命令</param>
        public void Order(string colName, CustomSortCommand sortCommand)
        {
            if (sortCommand == null)
            {
                return;
            }
            //如果没有设置高亮filter
            if (this.sortCommand == null)
            {
                this.sortCommand           = sortCommand;
                gridView.CustomColumnSort += gridView_CustomColumnSort;
            }
            else
            {
                //判断是否和当前filter一致
                if (this.sortCommand.Tag.Equals(sortCommand.Tag) == false)
                {
                    gridView.CustomColumnSort -= gridView_CustomColumnSort;
                    gridView.CustomColumnSort += gridView_CustomColumnSort;
                }
            }

            gridView.Columns[colName].SortMode  = ColumnSortMode.Custom;
            gridView.Columns[colName].SortOrder = DevExpress.Data.ColumnSortOrder.Ascending;
            //gridControl.RefreshDataSource();
        }
コード例 #2
0
 public void RemoveSortByCommand()
 {
     try
     {
         this.sortCommand           = null;
         gridView.CustomColumnSort -= gridView_CustomColumnSort;
     }
     catch (Exception) { }
     finally
     {
         for (int index = 0; index < this.gridView.RowCount; index++)
         {
             this.gridView.RefreshRow(index);
         }
     }
 }