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

Exporting Filtered Grids

3 Answers 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas Hundley
Top achievements
Rank 1
Thomas Hundley asked on 17 Jul 2008, 10:02 PM
Hi.  Is there a way to Export the data from a Filtered Grid without exporting the controls in the Command Item Template?  The ExportDataOnly does not appear to do the trick.

Everything about Exporting is working great from within the command item template until I apply a filter.  The controls are being exported and look horrible (not rendered properly, etc). 

Two side notes: 1) Exporting to CSV works fine with the filter (no controls) and 2) PDF's simply don't work- I get a "System.SystemException: Telerik.Web.Apoc.ApocException: fo:block must be child of fo:basic-link ... " exception.

My grid's item command method:
           case "Export":  
                {  
                    GridCommandItem item = e.Item as GridCommandItem;  
                    CheckBox cbIgnorePaging = item.FindControl("cbIgnorePaging") as CheckBox;  
                    RadComboBox rddlExport = item.FindControl("rddlExport") as RadComboBox;  
 
                    rgDigitalCertificateAssignments.ExportSettings.OpenInNewWindow = true;  
                    rgDigitalCertificateAssignments.ExportSettings.ExportOnlyData = true;  
                    rgDigitalCertificateAssignments.ExportSettings.IgnorePaging = cbIgnorePaging.Checked;  
                    rgDigitalCertificateAssignments.ExportSettings.FileName = "CertificateHistory";  
 
                    switch (rddlExport.SelectedValue)  
                    {  
                        case "excel":  
                            {  
                                rgDigitalCertificateAssignments.MasterTableView.GridLines = GridLines.Both;  
                                rgDigitalCertificateAssignments.ExportSettings.Excel.Format = GridExcelExportFormat.Html;  
                                rgDigitalCertificateAssignments.MasterTableView.ExportToExcel();  
 
                                break;  
                            }  
                        case "word":  
                            {  
                                rgDigitalCertificateAssignments.MasterTableView.ExportToWord();  
                                break;  
                            }  
                        case "csv":  
                            {  
                                rgDigitalCertificateAssignments.ExportSettings.Csv.ColumnDelimiter = GridCsvDelimiter.Tab;  
                                rgDigitalCertificateAssignments.MasterTableView.ExportToCSV();  
                                break;  
                            }  
                        case "pdf":  
                            {  
                                rgDigitalCertificateAssignments.ExportSettings.Pdf.AllowAdd = false;  
                                rgDigitalCertificateAssignments.ExportSettings.Pdf.AllowCopy = true;  
                                rgDigitalCertificateAssignments.ExportSettings.Pdf.AllowModify = false;  
                                rgDigitalCertificateAssignments.ExportSettings.Pdf.AllowPrinting = true;  
                                
                                rgDigitalCertificateAssignments.MasterTableView.ExportToPdf();  
                                break;  
                            }  
                    }                      
                    break;  
                }  
        } 
Please advise.

Thank you,
Tom

3 Answers, 1 is accepted

Sort by
0
Thomas Hundley
Top achievements
Rank 1
answered on 17 Jul 2008, 10:29 PM
Edit: Ticket Submitted for this issue

Your ticket ID is : 150558

Thanks,
Tom
0
Iana Tsolova
Telerik team
answered on 18 Jul 2008, 09:57 AM
Hello Thomas Hundley,

Please find the answer to your questions in the support ticket open.

Let us know if we could help you further.

Best wishes,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Thomas Hundley
Top achievements
Rank 1
answered on 21 Jul 2008, 07:52 PM

Thanks Iana,
I figured out what was causing my problem.  I was subscribing to the PreRender method and manipulating the grid to preserve filtering and page size during the session. 

I added a bool to the export command to set "isExporting" to True, and then it works fine.  I've attached my PreRender for reference.  I supppose it is the Rebind that was doing it?  I'm not too worried about it since I've gotten my problem fixed.

As always, thanks for the great support.

    protected void rgInquiries_PreRender(object sender, EventArgs e)  
    {  
        if (!isExporting)  
        {  
            #region Filter & Page Size  
            pageSize = rgInquiries.MasterTableView.PageSize;  
            if (!string.IsNullOrEmpty(rgInquiries.MasterTableView.FilterExpression))  
            {  
                Session[sessionFilterExpression] = rgInquiries.MasterTableView.FilterExpression;  
                foreach (Object key in filterHashTable.Keys)  
                {  
                    GridColumn column = rgInquiries.MasterTableView.GetColumnSafe(key.ToString());  
                    Pair filterPair = (Pair)filterHashTable[key];  
                    column.CurrentFilterValue = filterPair.Second.ToString();  
                }  
                rgInquiries.Rebind();  
            }  
            #endregion  
        }  
    } 

Tags
Grid
Asked by
Thomas Hundley
Top achievements
Rank 1
Answers by
Thomas Hundley
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or