我有 2 个可以在行区域中使用的字段。其中一个是“ID”,另一个是“Name”。放到行区的时候,是按ID排序的,ok。但是当我把“名称”字段放在那里时,它是按值排序的。
我正在尝试按 ID 排序而不显示但尚未克服。
Here the documentatio n 但不是很清楚能不能解决我的问题。
有人知道怎么解决吗?
编辑:示例:
alt text http://community.devexpress.com/forums/214248/PostAttachment.aspx
最佳答案
这是适合您的代码:
private void pivotGridControl1_CustomFieldSort(object sender, DevExpress.XtraPivotGrid.PivotGridCustomFieldSortEventArgs e) {
if(e.Field.FieldName == "Name") {
int value1 = Convert.ToInt32(e.GetListSourceColumnValue(e.ListSourceRowIndex1, "ID"));
int value2 = Convert.ToInt32(e.GetListSourceColumnValue(e.ListSourceRowIndex2, "ID"));
e.Result = Comparer.Default.Compare(value1, value2);
if(e.SortOrder == DevExpress.XtraPivotGrid.PivotSortOrder.Descending)
e.Result = -e.Result;
e.Handled = true;
}
}
有用吗?
关于c# - ASPxPivotGrid 排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3225188/