本文介绍了基于隐藏列对数据透视网格RowArea进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HTML:
HTML:
<dx:ASPxPivotGrid ID="ASPxPivotGrid1" Width="500px"
önCustomFieldSort="ASPxPivotGrid1_CustomFieldSort" runat="server"
ClientIDMode="AutoID">
<Fields>
<dx:ivotGridField Area="RowArea"
FieldName="ContainerOrder" Caption="Container Order" SortMode="Custom" AreaIndex="0" />
<dx:ivotGridField Area="RowArea"
FieldName="Status" Caption="Status" AreaIndex="1" />
<dx:ivotGridField Area="ColumnArea"
FieldName="Month" SortMode="Custom" AreaIndex="2" Caption="Month" />
<dx:ivotGridField Area="DataArea"
FieldName="Count" AreaIndex="3" />
</Fields>
<OptionsView ShowFilterHeaders="False" ShowFilterSeparatorBar="False" ShowColumnHeaders="False" ShowDataHeaders="False" ShowRowHeaders="False" />
<OptionsPager RowsPerPage="20"></OptionsPager>
</dx:ASPxPivotGrid>
Source Tried适用于可见列:
Source Tried which works for visible columns:
List<String> l = new List<string>(new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
protected void ASPxPivotGrid1_CustomFieldSort(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomFieldSortEventArgs e)
{
if (e.Field.FieldName == "Month")
{
string val1 = Convert.ToString(e.Value1);
string val2 = Convert.ToString(e.Value2);
e.Result = l.IndexOf(val1).CompareTo(l.IndexOf(val2));
e.Handled = true;
}
}
推荐答案
List<string> l = new List<string>(new string[] { "1","2","3","4" });
protected void ASPxPivotGrid1_CustomFieldSort(object sender, DevExpress.Web.ASPxPivotGrid.PivotGridCustomFieldSortEventArgs e)
{
if (e.Field.FieldName == "containerorder")
{
string val1 = Convert.ToString(e.Value1);
string val2 = Convert.ToString(e.Value2);
e.Result = l.IndexOf(val1).CompareTo(l.IndexOf(val2));
e.Handled = true;
}
}
</string></string>
希望这会有所帮助。
hope this will help.
这篇关于基于隐藏列对数据透视网格RowArea进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!