I have a RadGrid with a datasource and I added 4 more columns manually and I populate these 4 columns in the server side.
When I try to export the RadGrid data, the 4 columns that I added manually doesn't display the cell values.
Is there a configuration that I have to set?
Code client-side:
<
telerik:RadGrid
ID
=
"radGridOLAUtilization"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
DataSourceID
=
"sqlDataSource"
CellSpacing
=
"-1"
>
<
ExportSettings
ExportOnlyData
=
"true"
></
ExportSettings
>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
></
GroupingSettings
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"False"
/>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"sqlDataSource"
AutoGenerateColumns
=
"False"
UseAllDataFields
=
"true"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"PalletID"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter PalletID column"
HeaderText
=
"Pallet ID"
SortExpression
=
"PalletID"
UniqueName
=
"PalletID"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Station"
FilterControlAltText
=
"Filter Station column"
HeaderText
=
"Station"
SortExpression
=
"Station"
UniqueName
=
"Station"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StartDateTime"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter StartDateTime column"
HeaderText
=
"Start DateTime"
SortExpression
=
"StartDateTime"
UniqueName
=
"StartDateTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"EndDateTime"
DataType
=
"System.DateTime"
FilterControlAltText
=
"Filter EndDateTime column"
HeaderText
=
"End DateTime"
SortExpression
=
"EndDateTime"
UniqueName
=
"EndDateTime"
HeaderStyle-HorizontalAlign
=
"Center"
> </
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DeltaTime"
DataType
=
"System.TimeSpan"
FilterControlAltText
=
"Filter DeltaTime column"
HeaderText
=
"Delta Time"
ReadOnly
=
"True"
SortExpression
=
"DeltaTime"
UniqueName
=
"DeltaTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<!-- Columns added manually -->
<
telerik:GridBoundColumn
DataField
=
"TotalTime"
DataType
=
"System.TimeSpan"
FilterControlAltText
=
"Filter TotalTime column"
HeaderText
=
"Total Time"
ReadOnly
=
"True"
SortExpression
=
"TotalTime"
UniqueName
=
"TotalTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
Display
=
"false"
DataField
=
"DownTime"
DataType
=
"System.TimeSpan"
FilterControlAltText
=
"Filter DownTime column"
HeaderText
=
"DownTime"
ReadOnly
=
"True"
SortExpression
=
"DownTime"
UniqueName
=
"DownTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataType
=
"System.TimeSpan"
FilterControlAltText
=
"Filter AccumulatedDownTime column"
HeaderText
=
"Accumulated DownTime"
ReadOnly
=
"True"
SortExpression
=
"AccumulatedDownTime"
UniqueName
=
"AccumulatedDownTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataType
=
"System.String"
FilterControlAltText
=
"Filter UtilizationTime column"
HeaderText
=
"Utilization Time"
ReadOnly
=
"True"
SortExpression
=
"UtilizationTime"
UniqueName
=
"UtilizationTime"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Server-side:
protected
void
Page_Load(
object
sender, EventArgs e)
{
double
AccumulatedDeltaTime = 0;
for
(
int
i = 0; i < radGridOLAUtilization.Items.Count; i++)
{
TableCell accumulatedDownTimeCell = radGridOLAUtilization.Items[i][
"AccumulatedDownTime"
];
TableCell DownTimeCell = radGridOLAUtilization.Items[i][
"DownTime"
];
TableCell deltaTimeCell = radGridOLAUtilization.Items[i][
"DeltaTime"
];
TableCell accumulatedUtilizationTimeCell = radGridOLAUtilization.Items[i][
"UtilizationTime"
];
TableCell totalTimeCell = radGridOLAUtilization.Items[i][
"TotalTime"
];
AccumulatedDeltaTime += TimeSpan.Parse(deltaTimeCell.Text).TotalSeconds;
if
(i == 0)
{
accumulatedDownTimeCell.Text =
"00:00:00"
;
accumulatedUtilizationTimeCell.Text =
"100%"
;
totalTimeCell.Text = deltaTimeCell.Text;
}
else
{
TableCell previousAccumulatedDownTimeCell = radGridOLAUtilization.Items[i - 1][
"AccumulatedDownTime"
];
TableCell previousTotalTimeCell = radGridOLAUtilization.Items[i - 1][
"TotalTime"
];
double
accumulatedDownTime = TimeSpan.Parse(previousAccumulatedDownTimeCell.Text).TotalSeconds + TimeSpan.Parse(DownTimeCell.Text).TotalSeconds;
accumulatedDownTimeCell.Text = TimeSpan.FromSeconds(accumulatedDownTime).ToString();
int
accumulatedUtilizationTime = (
int
)(100 * AccumulatedDeltaTime / (AccumulatedDeltaTime + accumulatedDownTime));
accumulatedUtilizationTimeCell.Text = accumulatedUtilizationTime.ToString() +
"%"
;
double
totalTime = AccumulatedDeltaTime + accumulatedDownTime;
totalTimeCell.Text = TimeSpan.FromSeconds(totalTime).ToString();
}
}
}
protected
void
btnExportToExcel_Click(
object
sender, EventArgs e)
{
//radGridOLAUtilization.ExportSettings.Excel.Format = GridExcelExportFormat.Xlsx;
radGridOLAUtilization.ExportSettings.FileName =
"Alerts Data"
;
radGridOLAUtilization.ExportSettings.IgnorePaging =
true
;
//radGridOLAUtilization.MasterTableView.ExportToExcel();
radGridOLAUtilization.MasterTableView.ExportToCSV();
}