Invoke the PDF export from the Toolbar component

4 posts, 1 answers
  1. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 31 Mar 2015 Link to this post

    Hi,

    I can see that the Grid component can produce PDF (and Excel) exports, which is ideal.

    But, how can I invoke the functionality from outside of the native Grid toolbar?

    In the example below, I want to invoke the PDF export of the Grid using the Toolbar component (though it could be any external stimulus)


    01.@(Html.Kendo().ToolBar()
    02.        .Name("ToolBar")
    03.        .Items(items =>
    04.        {
    05.            items.Add().Type(CommandType.SplitButton).Text("Export").ImageUrl(Url.Content("~/Content/web/toolbar/save.png")).MenuButtons(menuButtons =>
    06.            {
    07.                menuButtons.Add().Text("Export to Excel").ImageUrl(Url.Content("~/Content/web/toolbar/save.png"));
    08.                menuButtons.Add().Text("Export to PDF").ImageUrl(Url.Content("~/Content/web/toolbar/upload.png"));
    09.            });     
    10.        })
    11.    )  
    12.    @(Html.Kendo().Grid<RequestWorkflowWithWatcherViewModel>()
    13.          .Name("grid")
    14.          .Columns(columns =>
    15.          {
    16.// columns stuff
    17.          })
    18.          .ToolBar(tools =>
    19.              tools.Pdf())
    20.          .Pdf(pdf => pdf
    21.                .AllPages()
    22.                .FileName("Kendo UI Grid Export.pdf")
    23.                .ProxyURL(Url.Action("EnquiryExportToPdf", "Home"))
    24.            )        
    25. 
    26.          ))

    Ultimately I want to do the same with Excel.

    Any ideas would be welcome.

    Many thanks

    Nathan
  2. Answer
    Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 02 Apr 2015 Link to this post

    Hello Nathan,

     

    You can call the saveAsPdf() method, of the grid, from anywhere. Here is the documentation about it:

     

    http://docs.telerik.com/kendo-ui/api/javascript/ui/grid#methods-saveAsPDF

     

    Regards,
    Kiril Nikolov
    Telerik
     

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

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Nathan J Pledger
    Nathan J Pledger avatar
    95 posts
    Member since:
    Apr 2006

    Posted 08 Apr 2015 in reply to Kiril Nikolov Link to this post

    Thanks very much, Kiril. That has sorted it.
  5. Kiril Nikolov
    Admin
    Kiril Nikolov avatar
    2564 posts

    Posted 09 Apr 2015 Link to this post

    Hello Nathan,

     

    Happy to help!

     

    Regards,
    Kiril Nikolov
    Telerik
     

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

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready