I have a RadGrid, with a RadFilter applied to it. I am not using RadAjaxPanel or any Ajax controls.
When I execute a RadGrid.MasterTableView.ExportToCSV(), I do not get any data returned when IgnorePaging = true.
If I set IgnorePaging = false, I get exported data, but only the first page.
How do I get the full dataset of the grid when using RadFilter?
When I execute a RadGrid.MasterTableView.ExportToCSV(), I do not get any data returned when IgnorePaging = true.
If I set IgnorePaging = false, I get exported data, but only the first page.
How do I get the full dataset of the grid when using RadFilter?
4 Answers, 1 is accepted
0

Karl
Top achievements
Rank 1
answered on 29 Mar 2014, 01:10 AM
I have tried another approach also. I changed the grid binding to GridNeedDataSource. But now it throws an exception when I try to apply the RadFilter at the .LoadSettings(query)
Anyone experience these challenges?
Anyone experience these challenges?
0

Princy
Top achievements
Rank 2
answered on 01 Apr 2014, 09:32 AM
Hi Karl,
I was not able to replicate such an issue at my end. Please try the sample code snippet. If this doesn't help, provide your full code snippet.
ASPX:
C#:
Thanks,
Princy
I was not able to replicate such an issue at my end. Please try the sample code snippet. If this doesn't help, provide your full code snippet.
ASPX:
<
telerik:RadFilter
runat
=
"server"
ID
=
"RadFilter1"
FilterContainerID
=
"RadGrid1"
ShowApplyButton
=
"false"
>
</
telerik:RadFilter
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
AutoGenerateColumns
=
"false"
DataSourceID
=
"SqlDataSource1"
AllowPaging
=
"true"
AllowSorting
=
"true"
AllowFilteringByColumn
=
"true"
OnItemCommand
=
"RadGrid1_ItemCommand"
>
<
MasterTableView
IsFilterItemExpanded
=
"false"
CommandItemDisplay
=
"Top"
>
<
CommandItemTemplate
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"Apply filter"
CommandName
=
"FilterRadGrid"
>
</
telerik:RadButton
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridNumericColumn
DataField
=
"OrderID"
HeaderText
=
"OrderID"
DataType
=
"System.Int32"
>
</
telerik:GridNumericColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"OrderDate"
HeaderText
=
"OrderDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridNumericColumn
DataField
=
"ShipVia"
HeaderText
=
"ShipVia"
DataType
=
"System.Int32"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"ShipName"
HeaderText
=
"ShipName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:Button
ID
=
"btnExport"
runat
=
"server"
Text
=
"Export to CSV"
OnClick
=
"btnExport_Click"
/>
C#:
protected
void
RadGrid1_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName ==
"FilterRadGrid"
)
{
RadFilter1.FireApplyCommand();
}
}
protected
void
btnExport_Click(
object
sender, System.EventArgs e)
{
RadGrid1.ExportSettings.IgnorePaging =
true
;
RadGrid1.ExportSettings.ExportOnlyData =
true
;
RadGrid1.MasterTableView.ExportToCSV();
}
Thanks,
Princy
0

Karl
Top achievements
Rank 1
answered on 01 Apr 2014, 08:03 PM
Thanks Princy. This is the idea. I am passing in a querystring that retrieves the RadFilter filter/state string. I then call .LoadSettings(state) and then .FireApplyCommand() Below is similar to what I want to accomplish, minus checking for necessary postbacks, etc.
int FilterQuery;
protected void Page_Load(object sender, EventArgs e)
{
// Try parse the querystring to ensure it is an int. If not, display an error.
if (Int32.TryParse(Server.HtmlEncode(Request.QueryString["q"]), out FilterQuery))
{
FilterMenu.SelectedValue = FilterGridQuery.ToString();
Applyfilter(FilterQuery);
}
else
{
// Display error
}
}
public void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
var data = from x in db.Items
select x;
RadGrid1.DataSource = data;
}
public void btnExport_Click(object sender, EventArgs e)
{
RadGrid1.ExportSettings.IgnorePaging = true;
RadGrid1.ExportSettings.ExportOnlyData = true;
RadGrid1.MasterTableView.ExportToCSV();
}
protected void ApplyFilter(int filter)
{
var filter = from x in db.filters
select x.query;
RadFilter1.LoadSettings(filter.FirstOrDefault());
RadFilter1.FireApplyCommand();
}
0
Hello Karl,
I prepared a small sample and on my side it seems to work correctly. Could you please give it a try and let me know how it differs from your real setup.
Regards,
Kostadin
Telerik
I prepared a small sample and on my side it seems to work correctly. Could you please give it a try and let me know how it differs from your real setup.
Regards,
Kostadin
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.