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

Export from RadGridView with column individual precisions

4 Answers 78 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jiri
Top achievements
Rank 1
Jiri asked on 09 Dec 2016, 02:57 PM

Hi there,

I have found a problem exporting from RadGridView with individual precision for each column. My .dll does not support ExportToXlsx method. I use Export(Stream stream, GridViewExportOptions options) method.

There is definitely an option to set precision for number columns but only the same for all of them thru GridViewElementExportingEventArgs.

I can definitely make my export done by exporting the data from binding sources but there is one exception for aggregate functions results which are located at GridViewColumn footer in fact but at runtime cannot be obtained because Footer property of particular column is null and which are computed at your side code.

So I need know either how to set precision on columns individual according to some input thru Export(Stream stream, GridViewExportOptions options) method or how to obtain the string representation of aggregate functions located in column footer.

I definitely can compute aggregate function result separately but I really do not want to.

Thank you very much.

 

 

4 Answers, 1 is accepted

Sort by
0
Jiri
Top achievements
Rank 1
answered on 09 Dec 2016, 03:05 PM
Grammar corrections: … I need to know …, individually, … aggregate functions results located…, … compute aggregate functions results…
0
Dilyan Traykov
Telerik team
answered on 14 Dec 2016, 12:19 PM
Hello Jiri,

If I understood your requirements correctly, you can handle RadGridView's ElementExporting event and modify the exported values accordingly. Here's what I have in mind:

private void ClubsGrid_ElementExporting(object sender, GridViewElementExportingEventArgs e)
{
    if (e.Element == ExportElement.Cell)
    {
        var column = e.Context as Telerik.Windows.Controls.GridViewColumn;
        if (column.UniqueName == "StadiumCapacity")
        {
            e.Value = string.Format("{0:F2}", e.Value); // make necessary changes
        }
    }
}

Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jiri
Top achievements
Rank 1
answered on 14 Dec 2016, 07:19 PM

That is exactly what I was searching for. Maybe I would be able to find this solution If I ever knew that GridViewElementExportingEventArgs.Context holds GridViewColumn.

0
Dilyan Traykov
Telerik team
answered on 15 Dec 2016, 09:27 AM
Hello Jiri,

I'm glad to hear the provided example was helpful to you.

I would also like to thank you for your valuable feedback. We will consider adding this information to the respective articles of our official documentation.

If you have any other questions or concerns, do not hesitate to contact us again.

Regards,
Dilyan Traykov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Jiri
Top achievements
Rank 1
Answers by
Jiri
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or