I created columns in code, 3 to Row Area, rest in column area, and all those in row area are grouped by name, and I don't want any of grouping/sorting, because I sorted and grouped it as I want in stored procedure.
Any idea how to disable automatic grouping/sorting?
Thanks
Ref: Can I disable sort?
it's impossible to disable sorting. The PivotGridControl groups data
by identical values to calculate summaries. This operation requires
data to be sorted. Also, each row or column in the PivotGridControl
might be associated with multiple records in the data source. In other
words, there is no way to uniquely identify the rows and columns order
in the PivotGridControl.
In this case, it is necessary to sort data manually by handling the ASPxPivotGrid.CustomFieldSort event. Do your calculation of sorting and grouping at this event.Below, I have posted a code snippet, demonstrating how to disable sorting:
private void pivotGridControl1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e)
{
e.Result = e.ListSourceRowIndex1.CompareTo(e.ListSourceRowIndex2);
e.Handled = true;
}
Reference:
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
check the AspxPivotGrid Sorting section for help in your calculations.
ASPxPivotGrid's PivotGridOptionsCustomization.AllowSort
option.
The order in which field values are sorted is specified by a field's PivotGridFieldBase.SortOrder
property.
There is no way to prevent the data from being sorted. Basically, the ASPxPivotGrid is intended to perform cross calculation. To properly calculate results it is necessary to group data by fields that are used to calculate results. To group data it is necessary to sort rows correspondingly. For example, suppose that the underlying list contains the following data:
Row1: Caption1; Value1
Row2: Caption2; Value2
Row3: Caption2; Value3
Row4: Caption1; Value4
If it is necessary to construct rows based upon captions, then pivot must sort them, because otherwise there is an ambiguous on which caption should be displayed first of all.
As you can see from the above sample, it is impossible to completely disable sorting. However, you can apply your own custom sorting algorithm and using the CustomSorting event in which you should adjust the e.Result parameter based upon the current row position:
using DevExpress.XtraPivotGrid;
//...
void pivotGridControl1_CustomFieldSort(object sender, PivotGridCustomFieldSortEventArgs e) {
e.Result = Math.Sign(e.ListSourceRowIndex2 - e.ListSourceRowIndex1);
e.Handled = true;
}
Please also review the following article: Data Sorting