Unplanned
Last Updated: 28 Aug 2017 11:03 by ADMIN
ADMIN
Marin Bratanov
Created on: 28 Aug 2017 10:52
Category: Grid
Type: Bug Report
0
The Columns collection of the Export Infrastructure is not populated by columns that do not have HeaderStyle.Width set
If a column does not have width set, it will not populate the Columns collection of the ExportInfrastructure in the BiffExprorting event http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/exporting/export-formats/excel-biff-export

To be able to loop through all columns, you need to have width specified for them.

This change has been introduced in Q3 2014

If you cannot do this for the standard grid rendering when defining columns, you can use the Grid.PreRender event to loop all columns and set some width for them:


VB

    Protected Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender

        'workaround for BiffExporting event Columns collection not being populated if the column does not have width set
        Dim Grid As RadGrid = DirectCast(sender, RadGrid)
        If (Grid.IsExporting) Then
            For index = 0 To Grid.MasterTableView.Columns.Count - 1
                Grid.MasterTableView.Columns(index).HeaderStyle.Width = 100
            Next
        End If
    End Sub


C#

protected void RadGrid1_PreRender(object sender, System.EventArgs e)
{
	//workaround for BiffExporting event Columns collection not being populated if the column does not have width set
	RadGrid Grid = (RadGrid)sender;
	if ((Grid.IsExporting)) {
		for (index = 0; index <= Grid.MasterTableView.Columns.Count - 1; index++) {
			Grid.MasterTableView.Columns(index).HeaderStyle.Width = 100;
		}
	}
}
0 comments