Hi,
Iam creating a Class for Pivot grid for programatic creation of grid.
Example :
public static void Layouts(RadPivotGrid grid, int height, int width, Boolean widthtype, Boolean allowsorting)
{
grid.Skin = "Office2007";// set the Skin
grid.EmptyValue = "No data";
grid.Height = height; //Set the height of the grid in % or in pixcel
if (width > 0)
{
if (widthtype == false)
{
grid.Width = width; // set the Width of the grid in % or in pixcel
}
else
{
grid.Width = Unit.Percentage(width);
}
}
grid.AllowSorting = allowsorting;
grid.AllowFiltering = false;
grid.ShowFilterHeaderZone = false;
grid.ShowDataHeaderZone = false;
grid.ShowFilterHeaderZone = false;
grid.ShowRowHeaderZone = false;
grid.ClientSettings.Scrolling.AllowVerticalScroll = true;
grid.ClientSettings.Scrolling.SaveScrollPosition = true;
}
#endregion
//Set all the telerik Grid Page
#region LayoutPage
public static void LayoutPage(RadPivotGrid grid, int pagesize, Boolean allowpaging)
{
grid.PageSize = pagesize;//Set the Grid Page default page size
grid.AllowPaging = allowpaging;//Set Paging for a grid as true or false
// grid.PagerStyle.PageSizeControlType = "RadDropDownList";
}
#endregion
//This function is to set the visblity of Colum and Row total and Subtotal display
#region TotalSettings
public static void TotalSettings(RadPivotGrid grid, TotalsPosition ColumnGrandTotalsPosition, TotalsPosition ColumnsSubTotalsPosition, TotalsPosition RowGrandTotalsPosition, TotalsPosition RowsSubTotalsPosition)
{
grid.TotalsSettings.ColumnGrandTotalsPosition = ColumnGrandTotalsPosition;
grid.TotalsSettings.ColumnsSubTotalsPosition = ColumnsSubTotalsPosition;
grid.TotalsSettings.RowGrandTotalsPosition = RowGrandTotalsPosition;
grid.TotalsSettings.RowsSubTotalsPosition=RowsSubTotalsPosition;
}
#endregion
// bind the Datatable to grid
#region DataBind
public static void DataBinds(RadPivotGrid grid, DataTable dataTable, Boolean needdatasource)
{
grid.DataSource = dataTable;
if (!needdatasource)
{
grid.DataBind();
}
}
public static void DataBinds(RadPivotGrid grid, DataSet dataSet, Boolean needdatasource)
{
DataBinds(grid, dataSet.Tables[0], needdatasource);
}
#endregion
//here we define each column type and value and text
#region PivotgridColumnType
//To set the Grid header column groups
#region PivotGridRowFiled
public static void PivotGridRowFiled(RadPivotGrid grid, String datafield, String UniqueName, int Width,TelerikControlType Columntype,String contolID)
{
PivotGridRowField rowField = new PivotGridRowField();
if(Columntype!=TelerikControlType.None)
{
rowField.CellTemplate = new MyTemplate(datafield, Columntype.ToString(), Width - 2, contolID);
}
rowField.DataField = datafield;
rowField.UniqueName = UniqueName;
rowField.CellStyle.Width = Width;
grid.Fields.Add(rowField);
}
#endregion
#region PivotGridColumnFiled
public static void PivotGridColumnFiled(RadPivotGrid grid, String datafield, String UniqueName, int Width)
{
PivotGridColumnField columnField = new PivotGridColumnField ();
// rowField.CellTemplate=
columnField.DataField = datafield;
columnField.UniqueName = UniqueName;
columnField.CellStyle.Width = Width;
grid.Fields.Add(columnField);
}
#endregion
#region PivotGridAggregateFiled
public static void PivotGridAggregateFiled(RadPivotGrid grid, String datafield, String UniqueName, int Width,String DataFormatString,String totalformatString)
{
PivotGridColumnField aggregateField = new PivotGridColumnField ();
// rowField.CellTemplate=
aggregateField.DataField = datafield;
aggregateField.UniqueName = UniqueName;
aggregateField.CellStyle.Width = Width;
aggregateField.DataFormatString = DataFormatString;
aggregateField.TotalFormatString = totalformatString;
grid.Fields.Add(aggregateField);
}
#endregion
#endregion
now everything looks good but i need to create a cell template which has Lable,Div controls need to add in aggregate and in row Column.
is there any sample for creating cell template for Pivot grid by program.