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

[Solved] only exporting expanded detailtables

2 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
sf
Top achievements
Rank 1
sf asked on 09 Feb 2010, 01:41 AM
hi I have a radgrid with detailtables inside detailtables (3 level). At runtime I expand some mastertableview records to see the detailrecords, and expend some detailtables to see the 3rd level detailrecords.When I click on Export I want to export the mastertable and ONLY the expanded detailtables.
my export code is:
RadGrid1.MasterTableView.HierarchyDefaultExpanded = true;  
RadGrid1.MasterTableView.DetailTables[0].HierarchyDefaultExpanded = true;  
RadGrid1.AllowPaging = false;  
RadGrid1.MasterTableView.Rebind();  
RadGrid1.ExportSettings.OpenInNewWindow = true;  
RadGrid1.MasterTableView.ExportToCSV(); 


please help, thanks in advance

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Feb 2010, 12:29 PM
Hi ,

Try the code snippet below to export only the expanded items.

CS:
 protected void Button2_Click(object sender, EventArgs e) 
    { 
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.ExportSettings.OpenInNewWindow = true
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
           if (item.Expanded) 
            { 
                GridTableView childTable = (GridTableView)item.ChildItem.NestedTableViews[0];  
                foreach (GridDataItem childItem in childTable.Items) 
                { 
                    if (!childItem.Expanded) 
                    { 
                        childItem.Visible = false
                    } 
                } 
            } 
            else 
            { 
                item.Visible = false
            } 
        } 
 
        RadGrid1.MasterTableView.ExportToExcel(); 
    }  

Thanks
Shinu.
0
Daniel
Telerik team
answered on 10 Feb 2010, 07:13 PM
Hello,

You can also check this thread where I attached a runnable demo.

Regards,
Daniel
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Grid
Asked by
sf
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or