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

Export using NestedViewTemplate not working with Q1 2011

7 Answers 134 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dustin Tabor
Top achievements
Rank 1
Dustin Tabor asked on 24 May 2011, 08:39 PM
We have a RadGrid that contains columns and a NestedViewTemplate which contains a user control that only has a RadGrid.  The export functionality has been working fine since Jan 2010, but ever since updating to Q1 2011 we receive an Object Reference error each time we try to export.  The stack trace shows that "Telerik.Web.UI.GridTableView.PrepareExport()" is the function throwing the error.  All other RadGrid export functions work fine, but they do not contain a NestedViewTemplate that contains another RadGrid.

The only way that the export will work is if I set IgnorePaging to false, but then all data that is on the other pages do not get exported to the excel.  So basically anytime the IgnorePaging is not false, you get the object reference error.  Also, if I remove the user control and just leave the empty NestedViewTemplate elements, the export works all the time.  Only when the user control (which just contains a RadGrid) is within a NestedViewTemplate do I get the object reference error.

The user control within the nestedviewtemplate is always set to visible = false, however, when you export, the radgrid within the user control, which is always visible = false, has its OnNeedDataSource event fired and after this is when you get the object reference error.  Below is the call stack

Using 2010 Q3 Telerik assembly, this problem does not exists and the RadGrid within the user control that exists in the NestedViewTemplate does not have the OnNeedDataSource event fired when exporting.

[NullReferenceException: Object reference not set to an instance of an object.]
   Telerik.Web.UI.GridTableView.PrepareExport() +72
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly) +373
   Telerik.Web.UI.GridTableView.ClearTableViewControls(Control control, TableViewExporter exporter, GridTableView ownerTable) +597
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExportInternal(GridTableView tableView, Boolean ignorePaging, Boolean dataOnly) +670
   Telerik.Web.UI.Grid.Export.TableViewExporter.PrepareForExport() +59
   Telerik.Web.UI.Grid.Export.TableViewExporter.page_PreRender(Object sender, EventArgs e) +34
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnPreRender(EventArgs e) +8695510
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842


<

 

 

telerik:RadGrid ID="RadGridCustomers" runat="server" Width="100%" AllowSorting="true" SkinID="ExpandCollapse"

 

 

 

AllowPaging="true" OnItemDataBound="RadGridCustomers_ItemDataBound" PageSize="20"

 

 

 

OnItemCommand="RadGridCustomers_ItemCommand" OnNeedDataSource="RadGridCustomers_NeedDataSource">

 

 

 

<ExportSettings FileName="RelationshipList" />

 

 

 

<ClientSettings>

 

 

 

<Resizing AllowColumnResize="true" />

 

 

 

</ClientSettings>

 

 

 

<PagerStyle Mode="NextPrevAndNumeric" />

 

 

 

<MasterTableView DataKeyNames="CcnNumber" Name="CcnList">

 

 

 

 

<NestedViewTemplate>

 

 

 

<tcb:ViewCustomers ID="ViewCustomersByCcn" runat="server" Visible="false" />

 

 

 

</NestedViewTemplate>

 

 

 

<Columns>

 

 

 

<telerik:GridTemplateColumn HeaderText="Relationship Name" DataField="CcnName"

 

 

 

SortExpression="CcnName" HeaderStyle-Width="140px">

 

 

 

<ItemTemplate>

 

 

 

<asp:HyperLink ID="HyperLinkCcnAccountList" runat="server" Target="_blank"

 

 

 

NavigateUrl="#" ToolTip="View Accounts" />

 

 

 

</ItemTemplate>

 

 

 

</telerik:GridTemplateColumn>

 

 

 

</MasterTableView>

 

 

 

</telerik:RadGrid>

 


Thanks.

7 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 May 2011, 12:13 PM
Hello Dustin,

Can you please isolate the problem in a simplified demo and then submit it via regular support ticket? I have an idea what might cause this exception but I need to debug the code locally.
In the meantime, I recommend that you set the IgnorePaging property to false and manually disable the paging functionality prior to exporting. Please note that you don't need to re-enable the paging afterwards - this change will affect the exported file only.

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.

0
Dustin Tabor
Top achievements
Rank 1
answered on 31 May 2011, 11:23 PM
I've been trying to recreate with a simple web application with no luck, so for now we are just going to go back and use Q3 2010, but I will keep trying to recreate. 

Could you point me to an example on manually disabling the paging?  I'll give that a go with the Q1 2011, but I assumed you could just say AllowPaging = false, but I just get the first page of data and no other pages when exporting so I'm not certain.

Thanks.
0
Mira
Telerik team
answered on 01 Jun 2011, 11:00 AM
Hello Dustin,

Could you please rebind the grid after setting AllowPaging to false and let me know whether it works?

Regards,
Mira
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.

0
Marlon Santos
Top achievements
Rank 1
answered on 09 Jun 2011, 10:31 PM
Did this work???
0
Dustin Tabor
Top achievements
Rank 1
answered on 09 Jun 2011, 10:37 PM
We were getting to close to production release, so it was placed on the back burner and we just reverted back to Q3 2010, which we were using before.  So this issue will be revisted with our next release.  Just an FYI, we could not recreate the issue with a small sample application, so that put a kink in things as well.
0
Marlon Santos
Top achievements
Rank 1
answered on 10 Jun 2011, 03:29 PM
I figured out an work around for the export issue...

 

 

protected void RadGridHardware_ItemCreated(object sender, GridItemEventArgs e)

 

 

{

 

 

   if (e.Item is GridNestedViewItem)

 

 

   {

 

 

 

      if (excelExport)

 

 

      {

        e.Item.Controls.Clear();  //All controls in the GridNestedViewItem - does not impact the normal view

      }

   }
}

In the radgrid event RadGrid_ItemCommand(object source, GridCommandEventArgs e) I set a global variable called excelExport = true

 

 

 

 

switch (e.CommandName)

 

 

{

 

 

 

case "ExportToExcel":

 

 

 

 

this.excelExport = true;

 

 

 

 

 

 

break;

 

 

 

 

Now it works...

0
Mira
Telerik team
answered on 13 Jun 2011, 10:32 AM
Hello Marlon,

I am glad the issue is resolved.

Do not hesitate to contact us if any further issues with RadControls arise.

Greetings,
Mira
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
Dustin Tabor
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Dustin Tabor
Top achievements
Rank 1
Mira
Telerik team
Marlon Santos
Top achievements
Rank 1
Share this question
or