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

[Solved] Hierarchical Grid Export to excel

2 Answers 152 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Srinivas Nilagiri
Top achievements
Rank 1
Srinivas Nilagiri asked on 23 Feb 2010, 03:59 AM
Hi All,
I have a hierarchical grid with 3 levels. Every thing is fine so far. I need to give an option to the user to export data into a 'flat' grid (removing the hierarchy and repeating the data in parent view as one of columns). How to proceed with this, do I need to query one more time into a dataset and export from there or is there a better way of doing this. Please guide on this. Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Feb 2010, 10:39 AM
Hi,

Yes, you would need to requery the database and set the grid datasource for the mastertable by performing a join operation.This way you will have a flat grid.Once you rebind the grid the expanded state of the items will be lost and then you will be able to export the master rows alone. 

Thanks,
Princy
0
Srinivas Nilagiri
Top achievements
Rank 1
answered on 24 Feb 2010, 09:14 AM
Thank you Princy,
It works, but I need to do the following to show the DetailTable columns in MasterTableView. Hope this helps if any one is looking at the same issue.  

grd.DataSource = GetData();  
foreach (GridColumn col in grd.MasterTableView.DetailTables[0].Columns)  
{  
  col.ItemStyle.Wrap = false;  
  grd.MasterTableView.Columns.Add(col);  
}  
grd.MasterTableView.DetailTables.Clear(); 
Tags
Grid
Asked by
Srinivas Nilagiri
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Srinivas Nilagiri
Top achievements
Rank 1
Share this question
or