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

[Solved] GroupsDefaultExpanded="false" Causes Export to be Blank

4 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adam Hewgill
Top achievements
Rank 1
Adam Hewgill asked on 11 Nov 2009, 02:09 AM
I have a Grid with a Group setup. The grid has a CSV export button, uses an SqlDataSource, and is not ajaxified.

When GroupsDefaultExpanded="true" the export has all of the data but when GroupsDefaultExpanded="false" the export is empty.

How can I force the grid to export the data even though it begins with all groups collapsed?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 11 Nov 2009, 10:40 AM
Hello Adam,

You can set the GroupsDefaultExpanded property to true on the export button click:
c#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == RadGrid.ExportToCsvCommandName) 
        { 
            RadGrid1.ExportSettings.IgnorePaging = true
            RadGrid1.ExportSettings.OpenInNewWindow = true
            RadGrid1.ExportSettings.HideStructureColumns = true
            RadGrid1.MasterTableView.GroupsDefaultExpanded = true; 
        } 
    } 

Hope this helps..
Princy.
0
Adam Hewgill
Top achievements
Rank 1
answered on 11 Nov 2009, 11:07 AM
I just tried this and it doesn't fix the problem. The export is still blank.
    Protected Sub BookingsExportButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) 
        BookingGrid.MasterTableView.GroupsDefaultExpanded = True 
        BookingGrid.ExportSettings.IgnorePaging = True 
        BookingGrid.ExportSettings.OpenInNewWindow = True 
        BookingGrid.ExportSettings.FileName = "Bookings" & ddlTerm.Text 
        BookingGrid.MasterTableView.ExportToCSV() 
    End Sub 
 



0
Accepted
Yavor
Telerik team
answered on 16 Nov 2009, 07:51 AM
Hello Adam,

Attached to this message, is a small application, which handles a similar task.
I hope it gets you started properly.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Adam Hewgill
Top achievements
Rank 1
answered on 16 Nov 2009, 01:43 PM
In order to make the above attachment work I had to delete the System.Web.Extensions reference to an old version (1.xxx).

The actual answer to the problem appears to be that you need to both expand the groups and rebind the grid before exporting.

    Protected Sub BookingsExportButton_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs)   
        BookingGrid.ExportSettings.IgnorePaging = True   
        BookingGrid.ExportSettings.OpenInNewWindow = True   
        BookingGrid.ExportSettings.FileName = "Bookings" & ddlTerm.Text   
        BookingGrid.MasterTableView.GroupsDefaultExpanded = True   
        BookingGrid.MasterTableView.Rebind()   
        BookingGrid.MasterTableView.ExportToCSV()   
    End Sub   
Tags
Grid
Asked by
Adam Hewgill
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Adam Hewgill
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or