I have a main Grid and inside the item template of that grid i have placed 6 grids.
I have done this as i have to export to excel all the six grids data into one excel. This is working fine. The thing i am not able to figure out is how to display the total for some of the columns of my first grid.
below is my code block for the first grid.
In this excluding the first column i.e. project name i want to display the total for all the other columns.
I tried to use Column created event.
but this is not working please let me know how i can go about doing this i.e. in any other event like itemdatabound or something please let me know....
I have done this as i have to export to excel all the six grids data into one excel. This is working fine. The thing i am not able to figure out is how to display the total for some of the columns of my first grid.
below is my code block for the first grid.
<
telerik:RadGrid
ID
=
"radGridWrapper"
runat
=
"server"
Skin
=
"Web20"
ShowHeader
=
"false"
BorderStyle
=
"None"
Width
=
"100%"
onexcelmlexportstylescreated
=
"radGridWrapper_ExcelMLExportStylesCreated"
onexcelmlexportrowcreated
=
"radGridWrapper_ExcelMLExportRowCreated"
>
<
ExportSettings
OpenInNewWindow
=
"true"
/>
<
MasterTableView
AutoGenerateColumns
=
"true"
CellSpacing
=
"-1"
>
<
ItemTemplate
>
<
h4
style
=
"font-weight:bold;color:Black; width:100%;height:15px"
align
=
"left"
> Manpower Summary<
asp:Label
ID
=
"lblmansummary"
runat
=
"server"
Visible
=
"false"
></
asp:Label
></
h4
>
<
telerik:RadGrid
ID
=
"grdmanpower"
runat
=
"server"
OnNeedDataSource
=
"RadGrid_NeedDataSource"
AutoGenerateColumns
=
"False"
CellSpacing
=
"1"
GridLines
=
"Vertical"
Width
=
"100%"
AllowSorting
=
"true"
Skin
=
"Web20"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Font-Underline
=
"true"
HeaderStyle-Wrap
=
"false"
HeaderStyle-Font-Bold
=
"true"
HeaderStyle-Font-Names
=
"Arial"
FooterStyle-HorizontalAlign
=
"Right"
FooterStyle-Font-Bold
=
"true"
PagerStyle-Wrap
=
"false"
OnItemDataBound
=
"grdmanpower_ItemDataBound"
OnColumnCreated
=
"grdmanpower_ColumnCreated"
>
<
ItemStyle
Font-Names
=
"Arial"
></
ItemStyle
>
<
AlternatingItemStyle
Font-Names
=
"Arial"
/>
<
MasterTableView
AutoGenerateColumns
=
"false"
ShowFooter
=
"true"
UseAllDataFields
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Project Name"
HeaderText
=
"Project Name"
ItemStyle-Wrap
=
"false"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Project Name"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Total Hours Booked (including OT)"
HeaderText="Total Hours Booked<br/>(including OT)" DataFormatString="{0:f1}" UniqueName="Total Hours Booked (including OT)" ></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Booked Manpower (including OT,Abs and WO)"
HeaderText="Booked Manpower<br/>(including OT,Abs and WO)" UniqueName="Booked Manpower (including OT,Abs and WO)" ItemStyle-Width = "14%" DataFormatString="{0:f1}" ></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Present"
HeaderText
=
"Present"
ItemStyle-Width
=
"14%"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Present"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Abs"
HeaderText
=
"Abs"
ItemStyle-Width
=
"14%"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Abs"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Weekly Off"
HeaderText
=
"Weekly Off"
ItemStyle-Width
=
"16%"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Weekly Off"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Training"
HeaderText
=
"Training"
ItemStyle-Width
=
"14%"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Training"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Abs %"
HeaderText
=
"Abs %"
ItemStyle-Width
=
"14%"
DataFormatString
=
"{0:f1}"
UniqueName
=
"Abs %"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
MasterTableView
>
</
telerik:RadGrid
>
In this excluding the first column i.e. project name i want to display the total for all the other columns.
I tried to use Column created event.
if (e.Column is GridBoundColumn)
{
if (col.UniqueName != "Project Name")
{
col.Aggregate = GridAggregateFunction.Sum;
col.FooterText = " ";
col.HeaderStyle.Width = Unit.Pixel(30);
col.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
}
}