or
protected
void
RadGrid_AssetList_ItemCreated(
object
sender, GridItemEventArgs e )
{
if
(IsExportButtonClicked){
FormatPdfOutput(RadGrid_AssetList);
var item = e.Item
as
GridDataItem;
if
(item !=
null
){
var dataItem = item;
foreach
(TableCell cell
in
dataItem.Cells){
cell.Style[
"text-align"
] =
"center"
;
}
}
else
{
var gridHeaderItem = e.Item
as
GridHeaderItem;
if
(gridHeaderItem !=
null
){
var headerItem = gridHeaderItem;
foreach
(TableCell cell
in
headerItem.Cells){
cell.Style[
"text-align"
] =
"center"
;
}
}
else
{
var gridFooterItem = e.Item
as
GridFooterItem;
if
(gridFooterItem !=
null
){
var footerItem = gridFooterItem;
foreach
(TableCell cell
in
footerItem.Cells){
cell.Style[
"text-align"
] =
"center"
;
}
}
}
}
}
}
private
void
FormatPdfOutput(RadGrid radGrid){
radGrid.ExportSettings.IgnorePaging =
true
;
radGrid.ExportSettings.ExportOnlyData =
true
;
radGrid.ExportSettings.HideStructureColumns =
true
;
double
marginWidth = radGrid.ExportSettings.Pdf.PageLeftMargin.Value
+ radGrid.ExportSettings.Pdf.PageRightMargin.Value;
double
printArea = radGrid.ExportSettings.Pdf.PageWidth.Value - marginWidth;
//if the print area of the page is smaller than the RadGrid width (total column width), change to
//percent based widths and evenly break up the columns.
if
(printArea < radGrid.Width.Value){
//count the number of columns that are both visible and have header text.
var visibleColumnCount = radGrid.Columns.Cast<GridColumn>().Count(column => column.Visible);
//calculate the percentage to evenly display all the columns
var tempWidth = 1.0 / (
double
)visibleColumnCount;
foreach
(GridColumn column
in
radGrid.Columns){
if
(column.Visible){
column.Visible = column.HeaderText.Length > 0;
}
column.HeaderStyle.Width = column.Visible
? Unit.Percentage(tempWidth)
: Unit.Percentage(0);
column.HeaderStyle.Wrap =
true
;
if
(column.Visible){
column.HeaderStyle.HorizontalAlign = column
as
GridNumericColumn ==
null
? HorizontalAlign.Left
: HorizontalAlign.Right;
}
}
}
}
<
asp:RadioButtonList
ID
=
"ShippingAddressRadioButtonList"
runat
=
"server"
AutoPostBack
=
"true"
OnClick
=
"CheckoutButtonDisable()"
>
</
asp:RadioButtonList
>
<
asp:Panel
ID
=
"AddNewShippingPanel"
runat
=
"server"
Visible
=
"false"
DefaultButton
=
"AddNewSaveButton"
>
//Several textboxes and drop downs contained here.
</
asp:Panel
>
<
asp:Panel
ID
=
"CheckoutWrapperPanel"
runat
=
"server"
>
//All page content here
</
asp:Panel
>
<
telerik:AjaxSetting
AjaxControlID
=
"ShippingAddressRadioButtonList"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"CheckoutWrapperPanel"
LoadingPanelID
=
"LoadingPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>