magritton
7/24/2014 - 11:53 AM

This removes specific columns from a Pivot Grid by using the oncustomfield event. In this example I removed columns 1 and 7 as long as they

This removes specific columns from a Pivot Grid by using the oncustomfield event. In this example I removed columns 1 and 7 as long as they were of a certain field type.

protected void pvGrid_CustomFieldValueCells(object sender, PivotCustomFieldValueCellsEventArgs e)
        {
            for (int i = e.GetCellCount(true) - 1; i >= 0; i--)
            {
                FieldValueCell cell = e.GetCell(true, i);
                if (cell == null) continue;

                if (cell.Field == fieldSumofOptimumYearSales)
                {
                    if (i == 7 || i == 1)
                    {
                        e.Remove(cell);
                    }
                   // if (object.Equals(cell.Value, 0)) //12 - december
                       
                }
            }
        }