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

[Solved] How to export to Excel selected items but without group titles

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andres
Top achievements
Rank 1
Andres asked on 20 Aug 2009, 12:08 AM
Hi everybody

I'm trying export selected items from grid without group titles, but I have not success

This is my code:

if (this.rgFacturas.SelectedItems.Count > 0) 
            { 
                GridGroupByExpressionCollection Coll = this.rgFacturas.MasterTableView.GroupByExpressions; 
                this.rgFacturas.MasterTableView.GroupByExpressions.Clear(); 
                                
 
                foreach (GridDataItem item in this.rgFacturas.MasterTableView.Items) 
                { 
                    item.Visible = item.Selected; 
                } 
 
                 
                this.rgFacturas.Rebind(); 
                this.rgFacturas.ExportSettings.ExportOnlyData = true
                this.rgFacturas.ExportSettings.OpenInNewWindow = true
                this.rgFacturas.MasterTableView.ExportToExcel(); 
 
                this.rgFacturas.MasterTableView.GroupByExpressions.AddRange(Coll); 
                this.rgFacturas.Rebind(); 
 
            } 


The first Rebind() is "clearing"  the selected items and the selected items are unselected, when ExportToExcel() is calling, all items are exported.

I need help, please
Some idea?

Thanks.



1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 20 Aug 2009, 02:19 PM
Hello Andres,

I recommend that you use the following code to export only selected columns without the grouping:
       RadGrid1.AllowPaging = false
       RadGrid1.GroupingEnabled = false
       RadGrid1.Rebind(); 
       foreach (GridDataItem item in RadGrid1.Items)   
        {   
            if (item.Selected == false)   
            {   
                item.Visible = false;   
            }   
        }   
        RadGrid1.ExportSettings.ExportOnlyData = true;   
        RadGrid1.ExportSettings.OpenInNewWindow = true;   
        RadGrid1.MasterTableView.ExportToExcel();   

Please let me know whether it helps.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Andres
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or