This is a migrated thread and some comments may be shown as answers.

Grid Export to excel + Filters

1 Answer 182 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karthik
Top achievements
Rank 1
Karthik asked on 11 Jul 2012, 06:01 PM
Hi,
 I am trying to export the grid by using the default telerik functionality which has the inline filters,
whenever i am trying to export to excel or word , the filters are shown up in the exported file even if the filtering has not been done ,

if (e.CommandName == RadGrid.ExportToExcelCommandName)
        {
            foreach (GridFilteringItem filter in radGrid.MasterTableView.GetItems(GridItemType.FilteringItem))
            {
                filter.Visible = false;
            }
            radGrid.MasterTableView.ExportToExcel();
        }

Even after using this part of code in the ItemCommand its not working, as the Needdatasource event is triggered after the ItemCommand the grid is rebinded  to loose all its settings.
Could you provide me help regarding this issue asap.

-Karthik

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jul 2012, 07:45 AM
Hello Karthik,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
 if (e.CommandName == RadGrid.ExportToExcelCommandName)
 {
    RadGrid1.AllowFilteringByColumn = false;
 }
 RadGrid1.MasterTableView.ExportToExcel();
}

Thanks,
Princy.
Tags
Grid
Asked by
Karthik
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or