我在代码中创建了列,3到行区,其余在列区,行区域中的所有列都是按名称分组的,我不想要任何分组/排序,因为我在存储过程中按需要对其进行了排序和分组。
你知道如何禁用自动分组/排序吗?
谢谢
发布于 2012-02-21 13:19:42
参考:Can I disable sort?
不可能禁用排序。PivotGridControl按相同的值对数据进行分组,以计算汇总。此操作需要对数据进行排序。此外,PivotGridControl中的每一行或每一列可能与数据源中的多个记录相关联。换句话说,无法唯一地标识PivotGridControl中的行和列的顺序。
在这种情况下,有必要通过处理ASPxPivotGrid.CustomFieldSort事件手动对数据进行排序。在这个event.Below上计算排序和分组,我已经发布了一个代码片段,演示了如何禁用排序:
private void pivotGridControl1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e)
{
e.Result = e.ListSourceRowIndex1.CompareTo(e.ListSourceRowIndex2);
e.Handled = true;
}参考资料:
Disable sorting feature by row/column
How to disable sorting and filtering features
SortOrder changed event handler
Regarding Grid Default Alphabetic Sorting
PivotGridCommands.ClearSorting Property
有关计算的帮助,请查看AspxPivotGrid Sorting部分。
ASPxPivotGrid的PivotGridOptionsCustomization.AllowSort选项。
字段值的排序顺序由字段的PivotGridFieldBase.SortOrder属性指定。
发布于 2012-02-21 12:46:01
没有办法阻止数据被排序。基本上,ASPxPivotGrid的目的是执行交叉计算。要正确计算结果,必须按用于计算结果的字段对数据进行分组。要对数据进行分组,需要对行进行相应的排序。例如,假设底层列表包含以下数据:
Row1: Caption1; Value1
Row2: Caption2; Value2
Row3: Caption2; Value3
Row4: Caption1; Value4如果有必要根据标题构造行,那么pivot必须对它们进行排序,否则首先应该显示哪个标题是不明确的。
从上面的示例中可以看到,完全禁用排序是不可能的。但是,您可以应用自己的自定义排序算法并使用CustomSorting事件,在该事件中应根据当前行位置调整e.Result参数:
using DevExpress.XtraPivotGrid;
//...
void pivotGridControl1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e) {
e.Result = Math.Sign(e.ListSourceRowIndex2 - e.ListSourceRowIndex1);
e.Handled = true;
}另请查看以下文章:Data Sorting
https://stackoverflow.com/questions/9329382
复制相似问题