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

Invoke the PDF export from the Toolbar component

3 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nathan J Pledger
Top achievements
Rank 2
Nathan J Pledger asked on 31 Mar 2015, 04:34 PM
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

3 Answers, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 02 Apr 2015, 08:45 AM

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.

 
0
Nathan J Pledger
Top achievements
Rank 2
answered on 08 Apr 2015, 04:40 PM
Thanks very much, Kiril. That has sorted it.
0
Kiril Nikolov
Telerik team
answered on 09 Apr 2015, 08:21 AM

Hello Nathan,

 

Happy to help!

 

Regards,
Kiril Nikolov
Telerik
 

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

 
Tags
Grid
Asked by
Nathan J Pledger
Top achievements
Rank 2
Answers by
Kiril Nikolov
Telerik team
Nathan J Pledger
Top achievements
Rank 2
Share this question
or