Hi All,
I have Radgrid for which i am using custom paging,and i need to give export to excel functionality for this Grid, and i am using RadGrid the Export to excel functionality, but it is not working some times , some times means
when the page load without giving any filter to grid this export to excel functionality is working , but when i give any column filter that time it is not working properly , even my grid is showing 100 records with 10 pages but when i click export button it is exporting only first page records (my Radgrid page size is 10 records per page.), even though i given IgnorePaging = True in Export setting.
but when i tried for the RadGrid where custom paging is not implimented for that RadGrid it is working
if You have any solution regarding this please help me to sharing.
My code is below
<telerik:RadGrid ID="rg_PlannedOrders" runat="server" OnNeedDataSource="rg_PlannedOrders_NeedDataSource" AllowMultiRowSelection="true"
AllowCustomPaging="true" OnDeleteCommand="rg_PlannedOrders_DeleteCommand" OnItemDataBound="rg_PlannedOrders_OnItemDataBound"
OnItemCommand="rg_PlannedOrders_ItemCommand" OnPageIndexChanged="rg_PlannedOrders_PageIndexChanged" PageSize="50" >
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="false" FileName = "PlannedOrderExc">
<Excel Format="Biff" />
</ExportSettings>
<MasterTableView CommandItemDisplay="Top" AllowMultiColumnSorting="true" AutoGenerateColumns="false">
CS side code is
protected void rg_PlannedOrders_ItemCommand(object sender, GridCommandEventArgs e)
{
try
{
switch (e.CommandName)
{
case RadGrid.ExportToExcelCommandName:
rg_PlannedOrders.AllowCustomPaging = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("DeleteCommandColumn")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("CheckBoxSelect_Detail")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("History")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("TemplateColumn_IsConsolidate")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("Temp_IsContractMRP")).Visible = false;
break;
default:
break;
}
string RgInvantoryCache = GetSearchCacheName();
GridSettingsPersister.SaveGridSettings(rg_PlannedOrders, e, RgInvantoryCache);
}
catch (Exception oException)
{ }
Thanks
I have Radgrid for which i am using custom paging,and i need to give export to excel functionality for this Grid, and i am using RadGrid the Export to excel functionality, but it is not working some times , some times means
when the page load without giving any filter to grid this export to excel functionality is working , but when i give any column filter that time it is not working properly , even my grid is showing 100 records with 10 pages but when i click export button it is exporting only first page records (my Radgrid page size is 10 records per page.), even though i given IgnorePaging = True in Export setting.
but when i tried for the RadGrid where custom paging is not implimented for that RadGrid it is working
if You have any solution regarding this please help me to sharing.
My code is below
<telerik:RadGrid ID="rg_PlannedOrders" runat="server" OnNeedDataSource="rg_PlannedOrders_NeedDataSource" AllowMultiRowSelection="true"
AllowCustomPaging="true" OnDeleteCommand="rg_PlannedOrders_DeleteCommand" OnItemDataBound="rg_PlannedOrders_OnItemDataBound"
OnItemCommand="rg_PlannedOrders_ItemCommand" OnPageIndexChanged="rg_PlannedOrders_PageIndexChanged" PageSize="50" >
<ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" HideStructureColumns="false" FileName = "PlannedOrderExc">
<Excel Format="Biff" />
</ExportSettings>
<MasterTableView CommandItemDisplay="Top" AllowMultiColumnSorting="true" AutoGenerateColumns="false">
CS side code is
protected void rg_PlannedOrders_ItemCommand(object sender, GridCommandEventArgs e)
{
try
{
switch (e.CommandName)
{
case RadGrid.ExportToExcelCommandName:
rg_PlannedOrders.AllowCustomPaging = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("DeleteCommandColumn")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("CheckBoxSelect_Detail")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("History")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("TemplateColumn_IsConsolidate")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("Temp_IsContractMRP")).Visible = false;
break;
default:
break;
}
string RgInvantoryCache = GetSearchCacheName();
GridSettingsPersister.SaveGridSettings(rg_PlannedOrders, e, RgInvantoryCache);
}
catch (Exception oException)
{ }
Thanks
11 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 30 Jul 2013, 04:56 AM
Hi Gajanan,
When you have custom paging enabled for your grid, you need to set the PageSize property of the grid to be equal to the VirtualItemCount in order to export all records successfully with IgnorePaging set to true.Edit your Code as:
ASPX:
C#:
The exporting feature works only with regular postbacks. This means, that the asynchronous postback should be canceled when performing an export.See the below code.
ASPX:
JS:
Hope this helps,
Thanks,
Princy
When you have custom paging enabled for your grid, you need to set the PageSize property of the grid to be equal to the VirtualItemCount in order to export all records successfully with IgnorePaging set to true.Edit your Code as:
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
ShowGroupPanel
=
"true"
runat
=
"server"
AllowPaging
=
"True"
AllowCustomPaging
=
"True"
VirtualItemCount
=
"10000"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
ExportSettings
Excel-Format
=
"Biff"
></
ExportSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
try
{
switch
(e.CommandName)
{
case
RadGrid.ExportToExcelCommandName:
RadGrid1.PageSize = RadGrid1.MasterTableView.VirtualItemCount;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
// Your Codes
RadGrid1.MasterTableView.ExportToExcel();
break
;
default
:
break
;
}
}
catch
(Exception oException)
{ }
}
The exporting feature works only with regular postbacks. This means, that the asynchronous postback should be canceled when performing an export.See the below code.
ASPX:
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
ClientEvents
OnRequestStart
=
"onRequestStart"
></
ClientEvents
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
JS:
<script type=
"text/javascript"
>
function
onRequestStart(sender, args) {
if
(args.get_eventTarget().indexOf(
"ExportTo"
) >= 0) {
args.set_enableAjax(
false
);
}
}
</script>
Hope this helps,
Thanks,
Princy
0

Gajanan
Top achievements
Rank 2
answered on 30 Jul 2013, 06:03 AM
hi Princy
thanks for quick replay . in my radgrid i mentioned VirtualItemCount="64000" and i added the the below code in Radgrid command event
rg_PlannedOrders.PageSize = rg_PlannedOrders.MasterTableView.VirtualItemCount;
rg_PlannedOrders.ExportSettings.ExportOnlyData = true;
rg_PlannedOrders.ExportSettings.IgnorePaging = true;
rg_PlannedOrders.ExportSettings.OpenInNewWindow = true;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("DeleteCommandColumn")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("CheckBoxSelect_Detail")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("History")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("TemplateColumn_IsConsolidate")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("Temp_IsContractMRP")).Visible = false;
rg_PlannedOrders.MasterTableView.ExportToExcel();
but still it is exporting only first page records in excel
thanks
thanks for quick replay . in my radgrid i mentioned VirtualItemCount="64000" and i added the the below code in Radgrid command event
rg_PlannedOrders.PageSize = rg_PlannedOrders.MasterTableView.VirtualItemCount;
rg_PlannedOrders.ExportSettings.ExportOnlyData = true;
rg_PlannedOrders.ExportSettings.IgnorePaging = true;
rg_PlannedOrders.ExportSettings.OpenInNewWindow = true;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("DeleteCommandColumn")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("CheckBoxSelect_Detail")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("History")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("TemplateColumn_IsConsolidate")).Visible = false;
((GridColumn)rg_PlannedOrders.Columns.FindByUniqueName("Temp_IsContractMRP")).Visible = false;
rg_PlannedOrders.MasterTableView.ExportToExcel();
but still it is exporting only first page records in excel
thanks
0

Princy
Top achievements
Rank 2
answered on 31 Jul 2013, 03:02 AM
Hi Gajanan,
I see that you are hiding some column during Export.Can you please try the below code snippet and see if it helps.
C#:
Thanks,
Princy
I see that you are hiding some column during Export.Can you please try the below code snippet and see if it helps.
C#:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
try
{
switch
(e.CommandName)
{
case
RadGrid.ExportToExcelCommandName:
RadGrid1.PageSize = RadGrid1.MasterTableView.VirtualItemCount;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
RadGrid1.MasterTableView.GetColumn(
"UniqueColumnName"
).Visible =
false
;
//Hide Column During Export
RadGrid1.MasterTableView.ExportToExcel();
break
;
default
:
break
;
}
}
catch
(Exception oException)
{ }
}
Thanks,
Princy
0

Gajanan
Top achievements
Rank 2
answered on 01 Aug 2013, 06:42 AM
hi princy,
thank you for replay
i used the code
to Hide columns while exporting
now the export to excel is working fine , but the problem is even i used above code to hide columns then also it is appearing in Excel
actually above code is not working even i tried for my old code that also not working,
i have a delete and Edit column in my Radgrid and i don't want this column while exporting to excel.
please help
Thanks
thank you for replay
i used the code
RadGrid1.MasterTableView.GetColumn(
"UniqueColumnName"
).Visible =
false
;
to Hide columns while exporting
now the export to excel is working fine , but the problem is even i used above code to hide columns then also it is appearing in Excel
actually above code is not working even i tried for my old code that also not working,
i have a delete and Edit column in my Radgrid and i don't want this column while exporting to excel.
please help
Thanks
0

Princy
Top achievements
Rank 2
answered on 01 Aug 2013, 07:51 AM
Hi ,
I tried to replicate the issue but no avail.When you set ExportOnlyData=true, it will exclude edit-command column,button-columns etc during export.Here is the code that i tried,i have attached the screenshot too.The Unit Price column is hidden during export.
To hide a column we use RadGrid1.MasterTableView.GetColumn("UniqueColumnName").Visible = false;
ASPX:
C#:
JS:
I tried to replicate the issue but no avail.When you set ExportOnlyData=true, it will exclude edit-command column,button-columns etc during export.Here is the code that i tried,i have attached the screenshot too.The Unit Price column is hidden during export.
To hide a column we use RadGrid1.MasterTableView.GetColumn("UniqueColumnName").Visible = false;
ASPX:
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
ClientEvents
OnRequestStart
=
"onRequestStart"
></
ClientEvents
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
></
telerik:AjaxUpdatedControl
>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
ToolTip
=
""
runat
=
"server"
>
</
telerik:RadAjaxLoadingPanel
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"true"
AllowCustomPaging
=
"True"
VirtualItemCount
=
"10000"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
ExportSettings
Excel-Format
=
"Biff"
>
</
ExportSettings
>
<
MasterTableView
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"true"
/>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"editrow"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
UniqueName
=
"deleterow"
CommandName
=
"Delete"
Text
=
"Delete"
ButtonType
=
"LinkButton"
>
</
telerik:GridButtonColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
try
{
switch
(e.CommandName)
{
case
RadGrid.ExportToExcelCommandName:
RadGrid1.PageSize = RadGrid1.MasterTableView.VirtualItemCount;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.OpenInNewWindow =
true
;
RadGrid1.MasterTableView.GetColumn(
"UnitPrice"
).Visible =
false
;
//To hide a column
RadGrid1.MasterTableView.ExportToExcel();
break
;
default
:
break
;
}
}
catch
(Exception oException)
{ }
}
JS:
<script type=
"text/javascript"
>
function
onRequestStart(sender, args) {
if
(args.get_eventTarget().indexOf(
"ExportTo"
) >= 0) {
args.set_enableAjax(
false
);
}
}
</script>
0

Hardik
Top achievements
Rank 1
answered on 09 Dec 2014, 11:36 AM
After doing this all things Export to Excel is working but immediate after that navigate to next page Navigation panel disappears.
0
Hello Hardik,
Could you please share with us the problematic page contents so we could examine the code? If you can provide us with a sample in which this problem can be observed that would be great.
Regards,
Angel Petrov
Telerik
Could you please share with us the problematic page contents so we could examine the code? If you can provide us with a sample in which this problem can be observed that would be great.
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

Hardik
Top achievements
Rank 1
answered on 18 Dec 2014, 02:29 PM
Hi,
I got the resolution. It was happening because of below code,
//protected override void SavePageStateToPersistenceMedium(object viewState)
//{
// Session["ViewState" + this.Page.ToString()] = viewState;
//}
//protected override object LoadPageStateFromPersistenceMedium()
//{
// return Session["ViewState" + this.Page.ToString()];
//}
But yes there is a bug in custom paging to avoid that bug we needs to set page index to 0 on ItemCommand event to get proper out put when we are on other page index than 0.
Thanks,
Hardik Vadher
I got the resolution. It was happening because of below code,
//protected override void SavePageStateToPersistenceMedium(object viewState)
//{
// Session["ViewState" + this.Page.ToString()] = viewState;
//}
//protected override object LoadPageStateFromPersistenceMedium()
//{
// return Session["ViewState" + this.Page.ToString()];
//}
But yes there is a bug in custom paging to avoid that bug we needs to set page index to 0 on ItemCommand event to get proper out put when we are on other page index than 0.
Thanks,
Hardik Vadher
0

Hardik
Top achievements
Rank 1
answered on 18 Dec 2014, 02:31 PM
gvOpenAR.CurrentPageIndex = 0;
gvOpenAR.PageSize = gvOpenAR.MasterTableView.VirtualItemCount;
gvOpenAR.ExportSettings.ExportOnlyData = true;
gvOpenAR.ExportSettings.IgnorePaging = true;
gvOpenAR.ExportSettings.OpenInNewWindow = true;
gvOpenAR.MasterTableView.ExportToExcel();
gvOpenAR.PageSize = gvOpenAR.MasterTableView.VirtualItemCount;
gvOpenAR.ExportSettings.ExportOnlyData = true;
gvOpenAR.ExportSettings.IgnorePaging = true;
gvOpenAR.ExportSettings.OpenInNewWindow = true;
gvOpenAR.MasterTableView.ExportToExcel();
0
Hello Hardik,
In order to research whether there is a problem on our end we would need the markup and code-behind of the page. That said could you please send them for review?
Regards,
Angel Petrov
Telerik
In order to research whether there is a problem on our end we would need the markup and code-behind of the page. That said could you please send them for review?
Regards,
Angel Petrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

saikumar
Top achievements
Rank 1
answered on 26 Sep 2017, 09:12 AM
Hi ,
I am also facing the same issue ,team could u pls help me on this.
I am using telerik rad grid attaching the code and snapshot , when I try to using paging records are loading perfectly without postback but parallel I tried excel download option when I click it ,its not working instead its loading all the records to the radgrid and paging gets disappeared . Thanks