When to set RadGrid.ExportSettings.FileName

6 posts, 0 answers
  1. JP
    JP avatar
    120 posts
    Member since:
    Aug 2011

    Posted 06 Jun 2012 Link to this post

    Hi,

    I want to use a generated filename for exports. I want to generate the filename only when the user does an export (I use the RadGrid's built-in feature for exporting by showing the export to Excel/Pdf/Word buttons).
    If I set the filename in CreateChildControls, it works fine.
    But in which event can I determine if there is an export running and change the filename? I tried the GridExporting event but it seems too late.
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jun 2012 Link to this post

    Hi,

    Try setting the FileName in the ItemCommand event as shown below.

    C#:
    protected void Radgrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.ExportToPdfCommandName)
        {
            Radgrid1.ExportSettings.FileName = "yourfilename";
        }
        if (e.CommandName == RadGrid.ExportToExcelCommandName)
        {
            Radgrid1.ExportSettings.FileName = "yourfilename";
        }
        if (e.CommandName == RadGrid.ExportToWordCommandName)
        {
            Radgrid1.ExportSettings.FileName = "yourfilename";
        }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dave
    Dave avatar
    2 posts
    Member since:
    May 2013

    Posted 08 Sep 2015 in reply to Shinu Link to this post

    This does not seem to work for me.   I want to add the date and time of the export in the file name but changing the filename at this point does nothing.   Anybody know if it's actually possible?
  5. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 10 Sep 2015 Link to this post

    Hi Dave,

    I've created a sample RadGrid web site to test the described behavior. Could you run the attached application and let me know about the result?

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. Dave
    Dave avatar
    2 posts
    Member since:
    May 2013

    Posted 11 Sep 2015 in reply to Eyup Link to this post

    Thanks for the reply.  This is pretty much exactly what we tried.  Seeing that this should work pushed me to dig further.      Our grids are created dynamically from code behind and we also use our own export button.      Turns out I can set the export name at the same time our export button is created and this works and the datetime changes each time I click on the button.
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 14 Sep 2015 Link to this post

    Hi,

    We are glad to hear that the example provided by my colleague Eyup helped to achieve your goal. Do not hesitate to contact us in case other questions arise.

    Regards,
    Pavlina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017