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

Radgrid export after filtering

3 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
nader
Top achievements
Rank 1
nader asked on 04 Nov 2010, 12:39 PM
i export radgrid to excel sheet , sometimes i make filter then export as it should export the filtered data not all the data........the code is :

            radGrid.MasterTableView.AllowPaging = false;
            radGrid.MasterTableView.AllowFilteringByColumn = false;

            radGrid.Rebind();

            radGrid.ExportSettings.FileName = "Logs Sheet_" + DateTime.Now.ToShortDateString();
            radGrid.MasterTableView.ExportToExcel();

line 2 which disable allowfilter is used to hide filter button and text in the same time it export all the data not the filtered and this is the problem .i tried to hide button but there no fuction to hide text..................

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 04 Nov 2010, 02:43 PM
Hello Nader,

You can try the following code to hide the filter row but export the filtered data.

C#:
protected void radGrid_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.ExportToExcelCommandName)
        {
            foreach (GridFilteringItem filter in radGrid.MasterTableView.GetItems(GridItemType.FilteringItem))
            {
                filter.Visible = false;
            }
            radGrid.MasterTableView.ExportToExcel();
        }
    }

-Shinu.
0
Daniel
Telerik team
answered on 07 Nov 2010, 01:20 PM
Hello Nader,

You can also try the following approach:
radGrid.ExportSettings.IgnorePaging = true;
radGrid.ExportSettings.ExportOnlyData = true;
radGrid.ExportSettings.FileName = "Logs Sheet_" + DateTime.Now.ToShortDateString();
radGrid.MasterTableView.ExportToExcel();

Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
nader
Top achievements
Rank 1
answered on 08 Nov 2010, 06:12 PM
thanx shinu for ur help.it worked with this snippet of code :):)
Tags
Grid
Asked by
nader
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Daniel
Telerik team
nader
Top achievements
Rank 1
Share this question
or