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

Limiting amount of text shown in column also limits in Excel Export

1 Answer 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 07 Apr 2015, 07:55 PM

Hello,

I was running into problems with too much text being displayed in certain columns within my grid. In ItemDataBound() I used the text.substring method (C#) to shorten the data to appropriate length. This was done similar to the directions provided in this post:

 http://www.telerik.com/forums/limit-amount-of-text-shown-in-data-column

Meanwhile I have implemented the Grid Excel export functionality. Unfortunately, my data within the Excel export is incomplete because it is being shortened to fit my columns. 

 

How can I limit the amount of text shown in a column, but still export all data when using the Excel export functionality?

 

Thanks,
Matt

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Apr 2015, 12:42 PM
Hello Matt,

You can achieve this requirement by including a condition statement in your logic:
bool isExporting = false;
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExportToExcelCommandName)
    {
        isExporting = true;
        if (!e.Item.OwnerTableView.OwnerGrid.ExportSettings.IgnorePaging)
        {
            RadGrid1.Rebind();
        }
    }
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (!isExporting && e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;
        item["ShipName"].Text = "new";
    }
}

Hope this helps. Please give it a try and let me know about the result.

Regards,
Eyup
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Grid
Asked by
Matthew
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or