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

Export with dynamic headergroup

5 Answers 209 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 20 Sep 2012, 05:17 PM
Using version 2012.2.724.40

I tried creating a headergroup in the markup and when I exported it, a blank line showed in the BIFF/Excel, but the headergroup headertext did not show.

I created a dynamic headergroup 
 

            Dim headerGroup As New GridColumnGroup
            dgSources.MasterTableView.ColumnGroups.Add(headerGroup)
            headerGroup.Name = "customgroup"
            headerGroup.HeaderText = "Some Title"

            For Each gcColumn As GridColumn In dgSources.MasterTableView.Columns
                If gcColumn.ColumnType = "GridBoundColumn" Then
                    gcColumn.ColumnGroupName = "customgroup"
                End If
            Next

Then tried to export it, and I got this error:

Invalid column name: customgroup


at Telerik.Web.UI.GridTableView.CreateMultiColumnHeaders(Boolean useDataSource, GridColumn[] copiedColumnSet, GridTHead thead)

   at Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource)

   at Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource)

   at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data)

   at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data)

   at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)

   at System.Web.UI.WebControls.DataBoundControl.PerformSelect()

   at Telerik.Web.UI.GridTableView.PerformSelect()

   at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()

   at Telerik.Web.UI.GridTableView.DataBind()

   at Telerik.Web.UI.RadGrid.DataBind()

   at Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason)

   at Telerik.Web.UI.RadGrid.RebindForExport()

   at Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly)

   at Telerik.Web.UI.Grid.Export.TableViewExporter.page_PreRender(Object sender, EventArgs e)

   at System.EventHandler.Invoke(Object sender, EventArgs e)

   at System.Web.UI.Control.OnPreRender(EventArgs e)

   at System.Web.UI.Control.PreRenderRecursiveInternal()

   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

5 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 25 Sep 2012, 11:24 AM
Hi Peter,

I am afraid currently exporting multicolumn headers with Excell BIFF format is not supported. As you probably know, autogenerated multicolumn headers are relatively new feature and our developers are working for their implementation in every scenario.

Thank you for your understanding and sorry for any inconvenience caused.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Scott
Top achievements
Rank 1
answered on 31 Oct 2012, 11:16 PM
Eyup, I received the same error for PDF and Word.  Does any export work with dynamic Column Groups?
-Scott
0
Eyup
Telerik team
answered on 05 Nov 2012, 12:52 PM
Hello Scott,

Both of the mentioned export formats are supported with programmatically created column groups. The reported error is not related to the export operation, rather to the creation and adding of the column groups. For example if you are adding them to a RadGrid's column collection declared in the mark-up:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
              ...
        GridColumnGroup orderDetails = new GridColumnGroup();
        RadGrid1.MasterTableView.ColumnGroups.Add(orderDetails);
        orderDetails.Name = "OrderDetails";
        orderDetails.HeaderText = "Order Details";
        orderDetails.ParentGroupName = "ProductDetails";
              ...
    }
}
Columns and detail tables should be added to the corresponding collection first, before the values for their properties are set, as stated in the following topic for regular columns:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html#Section1

I hope this will prove helpful.

Regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Scott
Top achievements
Rank 1
answered on 06 Nov 2012, 06:36 PM
Eyup, thanks for the suggestion. This helped some, in that the error is now clearer.  Instead of:
    "Invalid Column Name:"
the error now is:
    "Invalid Column Name: <GridColumnGroup.Name>"
where <GridColumnGroup.Name> is the name of the first column group. This error occurs during the "RadGrid.DataBind()" call, when the user triggers the "RadGrid.MasterTableView.ExportToPdf()" method.

-Scott

0
Scott
Top achievements
Rank 1
answered on 06 Nov 2012, 07:47 PM
OK, so the issue was a simple one. I failed to perform the "If (!IsPostback)" check in the Page_Load method. The corrected code is:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
        CreateAndFillGrid();
}

I now get correctly formatted Word docs, but the Excel & CSV are incomplete, and finally, the PDF works but is not pretty (see attached.) Hopefully, Telerik will keep improving the Export of Grouped Columns.  Thanks.



Tags
Grid
Asked by
Peter
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Scott
Top achievements
Rank 1
Share this question
or