I tried exporting a radgrid after filtering, and it export all data, and not filtered data.
It shouldn't work this way, I need to export only data according to filters.
The export method:
public void ExportToExcel()
{
string sCurentData = DateTime.Today.ToShortDateString();
string filename = "Users_Report_" + sCurentData;
UsersGrd.ExportSettings.IgnorePaging = true;
UsersGrd.ExportSettings.ExportOnlyData = true;
UsersGrd.ExportSettings.OpenInNewWindow = true;
UsersGrd.MasterTableView.ShowFooter = false;
UsersGrd.MasterTableView.Columns[8].Visible = false;
UsersGrd.MasterTableView.Columns[9].Visible = false;
UsersGrd.MasterTableView.Columns[10].Visible = false;
UsersGrd.MasterTableView.AllowFilteringByColumn = false;
UsersGrd.ExportSettings.FileName = filename;
UsersGrd.MasterTableView.ExportToExcel();
}
Ascx:
<telerik:RadGrid ID="UsersGrd" AutoGenerateColumns="False" runat="server" PagerStyle-AlwaysVisible="true" PageSize="10" OnNeedDataSource="UsersGrd_NeedDataSource"
Skin="Default" ShowStatusBar="True" ShowFooter="True" AllowPaging="True" CellSpacing="0" FooterStyle-CssClass="custom-footer" PagerStyle-CssClass="custom-footer"
GridLines="Horizontal" Width="1265px" AllowSorting="true" Style="margin-top:10px; border: 0px;margin-bottom:20px;" OnItemCommand="SubmitCommand" OnItemDataBound="grdUsers_ItemDataBound">
Need data source:
protected void UsersGrd_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
[....]
UsersGrd.DataSource = data;
}
What is the problem? Why is not working as it should?
Thanks.
It shouldn't work this way, I need to export only data according to filters.
The export method:
public void ExportToExcel()
{
string sCurentData = DateTime.Today.ToShortDateString();
string filename = "Users_Report_" + sCurentData;
UsersGrd.ExportSettings.IgnorePaging = true;
UsersGrd.ExportSettings.ExportOnlyData = true;
UsersGrd.ExportSettings.OpenInNewWindow = true;
UsersGrd.MasterTableView.ShowFooter = false;
UsersGrd.MasterTableView.Columns[8].Visible = false;
UsersGrd.MasterTableView.Columns[9].Visible = false;
UsersGrd.MasterTableView.Columns[10].Visible = false;
UsersGrd.MasterTableView.AllowFilteringByColumn = false;
UsersGrd.ExportSettings.FileName = filename;
UsersGrd.MasterTableView.ExportToExcel();
}
Ascx:
<telerik:RadGrid ID="UsersGrd" AutoGenerateColumns="False" runat="server" PagerStyle-AlwaysVisible="true" PageSize="10" OnNeedDataSource="UsersGrd_NeedDataSource"
Skin="Default" ShowStatusBar="True" ShowFooter="True" AllowPaging="True" CellSpacing="0" FooterStyle-CssClass="custom-footer" PagerStyle-CssClass="custom-footer"
GridLines="Horizontal" Width="1265px" AllowSorting="true" Style="margin-top:10px; border: 0px;margin-bottom:20px;" OnItemCommand="SubmitCommand" OnItemDataBound="grdUsers_ItemDataBound">
Need data source:
protected void UsersGrd_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
[....]
UsersGrd.DataSource = data;
}
What is the problem? Why is not working as it should?
Thanks.