Export from RadGridView with column individual precisions

5 posts, 0 answers
  1. Jiri
    Jiri avatar
    9 posts
    Member since:
    Nov 2016

    Posted 09 Dec 2016 Link to this post

    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.

     

     

  2. Jiri
    Jiri avatar
    9 posts
    Member since:
    Nov 2016

    Posted 09 Dec 2016 in reply to Jiri Link to this post

    Grammar corrections: … I need to know …, individually, … aggregate functions results located…, … compute aggregate functions results…
  3. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1171 posts

    Posted 14 Dec 2016 Link to this post

    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.
  4. Jiri
    Jiri avatar
    9 posts
    Member since:
    Nov 2016

    Posted 14 Dec 2016 in reply to Dilyan Traykov Link to this post

    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.

  5. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    1171 posts

    Posted 15 Dec 2016 Link to this post

    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.
Back to Top