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; } } |
Figure: pivot grid with numeric sorting