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

Export Subset of Grid Data

3 Answers 126 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 24 Jan 2011, 12:41 AM
I am trying to figure out how to best export a subset of data from a R.A.D. Grid. Specifically, I want to export only the selected items of the grid. It is a paged grid, non-hierarchical. If anyone knows a good way to do this, please let me know.

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jan 2011, 05:49 AM
Hello Peter,

The following code snippet shows how to export only selected items in grid.

C#:
protected void ExportBtn_Click(object sender, EventArgs e)
    {
        foreach (GridDataItem dataitem in RadGrid1.Items)
            {
                dataitem.Visible = dataitem.Selected;
            }
            RadGrid1.ExportSettings.OpenInNewWindow = true;
            RadGrid1.MasterTableView.ExportToExcel(); // exporting to Excel
    }

Thanks,
Princy.
0
Peter
Top achievements
Rank 1
answered on 24 Jan 2011, 11:41 PM
Hi, thanks for you reply.

I tried this and it's not working. During the post-back caused by the button, changes made to the visibility of columns are being reflected in the output. However, changes to the the visibility of grid data items has no effect; it still exports the entire data set.
0
Daniel
Telerik team
answered on 27 Jan 2011, 05:16 PM
Hello Peter,

If you have set IgnorePaging="true" or if you rebind RadGrid manually before exporting, you will have to use the ItemCreated/ItemDataBound event as explained in our documentation:
Word/Excel export (HTML-based)

Best regards,
Daniel
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Peter
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or