Unplanned
Last Updated: 24 Jan 2019 14:58 by Eric Moreau
Eric Moreau
Created on: 23 Jan 2019 18:24
Category: GridView
Type: Bug Report
1
Cannot export grid with GridViewComboBoxColumn inside a ColumnGroupsViewDefinition

Hi

I just found a strange issue using the latest bits of the Telerik RadGridView. 

I have a grid that contains ColumnGroupsViewDefinition. Inside one of the group, one of the column is a GridViewComboBoxColumn.

The grid shows correctly on the screen.

If I try to export it using GridViewSpreadExport, I get an exception saying "input string was not in a correct format".

The export works fine if:

-I don't have groups

-I export to HTML using ExportToHTML

-I export to HTML using ExportToCSV

 

Any help please?

2 comments
Eric Moreau
Posted on: 24 Jan 2019 14:58
the workaround seems to be working for now
ADMIN
Dess | Tech Support Engineer, Sr.
Posted on: 24 Jan 2019 11:38
Hello, Eric,      

Following the provided information I was able to replicate the error when RadGridView has a GridViewComboBoxColumn and a ColumnGroupsViewDefinition is applied. I have also attached my sample project for your reference. I confirm that this is an issue with the GridViewSpreadExport.

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments to it. I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to set the DisplayMember of the column to an empty string and thus export the ValueMember

SpreadExportRenderer exportRenderer = new SpreadExportRenderer();
GridViewComboBoxColumn comboColumn;
 
private void radButton1_Click(object sender, EventArgs e)
{
    comboColumn = this.radGridView1.Columns["CategoryID"] as GridViewComboBoxColumn;
    foreach (GridViewRowInfo row in this.radGridView1.Rows)
    {
        row.Cells["CategoryID"].Tag = comboColumn.GetLookupValue(row.Cells["CategoryID"].Value);
    }
     
    comboColumn.Tag = comboColumn.DisplayMember;
    comboColumn.DisplayMember = "";
     
    string fileName = @"..\..\export" + DateTime.Now.ToLongTimeString().Replace(":", "_") + ".xlsx";
    GridViewSpreadExport spreadExporter = new GridViewSpreadExport(this.radGridView1);
 
    spreadExporter.CellFormatting += spreadExporter_CellFormatting;
    spreadExporter.RunExport(fileName, exportRenderer);
    
    comboColumn.DisplayMember = comboColumn.Tag.ToString() ;
    comboColumn.Tag = null;
 
    Process.Start(fileName);
}
 
private void spreadExporter_CellFormatting(object sender, Telerik.WinControls.Export.CellFormattingEventArgs e)
{
    if (e.GridCellInfo != null && e.GridCellInfo.ColumnInfo != null && e.GridCellInfo.Tag != null && e.GridCellInfo.ColumnInfo.Name == "CategoryID")
    {
        exportRenderer.SetCellSelectionValue(e.GridCellInfo.Tag.ToString());
    }
}

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 
Attached Files: