Click here to Skip to main content
15,889,820 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
HTML:
ASP.NET
<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 which works for visible columns:

C#
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;
           }
       }
Posted
Updated 29-Apr-14 1:45am
v2

1 solution

you are very near to the solution.

as you did to change the order of the column based on month using list you can do the same using new list for container order.

i assume if 1,2,3,4 is your order the code will go like below.
C#
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.
 
Share this answer
 
Comments
Sanket Saxena 29-Apr-14 7:55am    
It helps...Thanks Mr. Ravi.. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900