Articles in this section
Category / Section

How to do numeric sorting in pivot grid

2 mins read

C#

this.pivotGrid1.PivotRows.Add(new PivotItem { FieldHeader = "Quantity", FieldMappingName = "Quantity", TotalHeader = "Total", Comparer = new QuantityComparer() });

 

public class QuantityComparer : IComparer

{

public int Compare(object x, object y)

{

if (x == null && y == null)

return 0;

if (x == null)

return -1;

if (y == null)

return 1;

if (Int32.Parse(y.ToString()) == Int32.Parse(x.ToString()))

return 0;

return Int32.Parse(y.ToString()) < Int32.Parse(x.ToString()) ? 1 : -1;

}

}


 

C:\Users\labuser\Dropbox\Screenshots\Screenshot 2014-06-10 15.38.41.png

Figure: pivot grid with numeric sorting

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied