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

Export 1 NestedViewTemplate to Html

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 08 Oct 2013, 08:48 AM
I have RadGrid with a quit extended NestedView where I show the details if the Item in a Html table. The Html is styled and there is photos in the table.

Now I would like to export only this NestedViewTemplate from this one Grid Item when the user click on a button inside the NestedViewTemplate.

Is this possible?

I have tried modify this sample:

http://www.telerik.com/community/forums/aspnet-ajax/grid/grid-export-to-excel-biff-format-hierarchy-and-selected-items.aspx#2816333 

By adding a NestedViewTemplate an expand those in the Prerender event. But first of I can't it to print the NestedViewTemplate and the export contains the headers.

Could some one point me in the right direction?  Thanks :-)

bool isExport = false;
protected void Button1_Click(object sender, EventArgs e)
{
    Session["SelectedItems"] = RadGrid1.SelectedItems;
    isExport = true;
 
    RadGrid1.ExportSettings.IgnorePaging = true;
    RadGrid1.ExportSettings.UseItemStyles = true;
    RadGrid1.ExportSettings.ExportOnlyData = true;
 
    RadGrid1.MasterTableView.ExportToExcel();
}
 
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    if (isExport)
    {
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
        {
            item.Expanded = true;
        }
    }
}

Anders Pedersen

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 11 Oct 2013, 06:55 AM
Hi Anders,

In the help topic which you have provided is demonstrates an approach which is suitable when you are using an ExcelML export format. Since you are trying to export a NestedViewTemplate I guess you  are using an HTML on. In this case you have to loop though all items and set their Visible property to false and leave visible only the one which is expanded. Please check out the following code snippet.
protected void Button1_Click(object sender, EventArgs e)
{
    foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
    {
        if (!item.Expanded)
        {
            item.Visible = false;
        }
    }
    RadGrid1.ExportSettings.IgnorePaging = true;
    RadGrid1.ExportSettings.UseItemStyles = true;
    RadGrid1.ExportSettings.ExportOnlyData = true;
  
    RadGrid1.MasterTableView.ExportToExcel();
}

Regards,
Kostadin
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Anders
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or