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

ExportToCsv of a Self-referencing hierarchy grid

5 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anette
Top achievements
Rank 1
Anette asked on 01 Oct 2008, 01:59 AM
Hello

Is there a way to export to CSV all the data in a self-referencing hierarchy grid?

I am using this command to export to CSV. But this only exports the data of the Parent.
RadGrid.MasterTableView.ExportToCSV();

I tried different solution in the forums but it is still not working. Any help on this matter?

Anette

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 03 Oct 2008, 01:02 PM
Hi Anette,

Hierarchy can be exported only to Excel/Word/Pdf but not to Csv. In case of Csv exporting only the data of the MasterTableView is exported.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Anette
Top achievements
Rank 1
answered on 05 Oct 2008, 08:53 PM
Hello Iana,

I tried exporting the grid to excel. However, only the expanded items were being exported. Is there a way to export all items even though they are not expanded? I already tried setting the HierarchyDefaultExpanded to true but it still fails to export all data.

RadGrid.MasterTableView.HierarchyDefaultExpanded = true;
RadGrid.MasterTableView.ExportToExcel();

Any help on this matter?

Anette
0
Anette
Top achievements
Rank 1
answered on 05 Oct 2008, 10:27 PM
Hello Iana,

Additionally, I need to hide the GridTemplateColumns that were programmatically created.

I tried using this line of code but it only hides the Edit column of the Parent Row. The Child rows still contains the Edit column.
RadGrid.MasterTableView.Columns.FindByUniqueName("Edit").Visible = false;

Any help on this matter?

Anette
0
Princy
Top achievements
Rank 2
answered on 06 Oct 2008, 03:44 AM
Hello Anette,

Try out the following code to export the detail tables even if not expanded  and also hide column in the  detail tables while exporting.
cs:
protected void Button1_Click(object sender, EventArgs e) 
    { 
 
        RadGrid1.MasterTableView.Columns.FindByUniqueName("ColumnUniqueName").Visible = false
        RadGrid1.MasterTableView.DetailTables[0].Columns.FindByUniqueName("ColumnUniqueName").Visible = false
        RadGrid1.MasterTableView.HierarchyDefaultExpanded = true
        RadGrid1.Rebind(); 
        RadGrid1.ExportSettings.ExportOnlyData = true
        RadGrid1.MasterTableView.ExportToExcel();       
    } 

Princy.
0
Shinu
Top achievements
Rank 2
answered on 06 Oct 2008, 03:48 AM
Hi Anette,

1.To export the entire Grid set the IgnorePaging Property to true.
 
CS:
protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadGrid2.ExportSettings.IgnorePaging = true
        RadGrid2.MasterTableView.ExportToExcel(); 
    } 

2. Try the following code snippet in the PreRender event to hide a column in the detail table.

CS:
protected void RadGrid2_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid2.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                GridTableView nestedView = ((GridDataItem)item).ChildItem.NestedTableViews[0]; 
                nestedView.GetColumn("FirstName").Visible = false
              
            } 
        } 
    } 


Regards
Shinu
Tags
Grid
Asked by
Anette
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Anette
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Share this question
or