|
| 1 | +--- |
| 2 | +title: Exclude Toolbar and Pager from Grid Pdf Export |
| 3 | +description: An example on how to export the Grid to Pdf without the toolbar and pager |
| 4 | +type: how-to |
| 5 | +page_title: Exclude Toolbar and Pager from Grid Pdf Export |
| 6 | +slug: grid-export-pdf-without-toolbar-pager |
| 7 | +tags: grid, export, pdf, toolbar, pager, ignore, exclude |
| 8 | +ticketid: 1143253 |
| 9 | +res_type: kb |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## Environment |
| 14 | +<table> |
| 15 | + <tr> |
| 16 | + <td>Product</td> |
| 17 | + <td>Grid for Progress® Kendo UI®</td> |
| 18 | + </tr> |
| 19 | + <tr> |
| 20 | + <td>Operating System</td> |
| 21 | + <td>All</td> |
| 22 | + </tr> |
| 23 | + <tr> |
| 24 | + <td>Browser</td> |
| 25 | + <td>All</td> |
| 26 | + </tr> |
| 27 | + <tr> |
| 28 | + <td>Browser Version</td> |
| 29 | + <td>All</td> |
| 30 | + </tr> |
| 31 | +</table> |
| 32 | + |
| 33 | +## Description |
| 34 | + |
| 35 | +When exporting a Kendo UI Grid to Pdf, the custom Toolbar and Pager are included; how can I prevent them from appearing in the exported Pdf file? |
| 36 | + |
| 37 | +## Solution |
| 38 | + |
| 39 | +Using the following CSS, we can prevent the Toolbar and Pager from being exported when using the export to pdf functionality of the Kendo UI Grid: |
| 40 | + |
| 41 | +````css |
| 42 | +.k-pdf-export .k-grid-toolbar, |
| 43 | +.k-pdf-export .k-pager-wrap |
| 44 | +{ |
| 45 | + display: none; |
| 46 | +} |
| 47 | +```` |
| 48 | + |
| 49 | +The result: |
| 50 | + |
| 51 | +```html |
| 52 | +<div id="example"> |
| 53 | + |
| 54 | + <div id="grid"></div> |
| 55 | + |
| 56 | + <script type="text/x-kendo-template" id="template"> |
| 57 | + <div class="toolbar"> |
| 58 | + <label class="category-label" for="category">Test input:</label> |
| 59 | + <input type="search" id="category" style="width: 150px"/> |
| 60 | + <a class="k-button k-button-icontext k-grid-pdf" href="\\#">Export to Pdf</a> |
| 61 | + </div> |
| 62 | + </script> |
| 63 | + <script id="rowTemplate" type="text/x-kendo-tmpl"> |
| 64 | + <tr data-uid="#: uid #"> |
| 65 | + <td class="photo"> |
| 66 | + <img src="../content/web/Employees/#: EmployeeID #.jpg" alt="#: EmployeeID #" /> |
| 67 | + </td> |
| 68 | + <td class="details"> |
| 69 | + <span class="name">#: FirstName# #: LastName# </span> |
| 70 | + <span class="title">Title: #: Title #</span> |
| 71 | + </td> |
| 72 | + <td class="country"> |
| 73 | + #: Country # |
| 74 | + </td> |
| 75 | + <td class="employeeID"> |
| 76 | + #: EmployeeID # |
| 77 | + </td> |
| 78 | + </tr> |
| 79 | + </script> |
| 80 | + <script id="altRowTemplate" type="text/x-kendo-tmpl"> |
| 81 | + <tr class="k-alt" data-uid="#: uid #"> |
| 82 | + <td class="photo"> |
| 83 | + <img src="../content/web/Employees/#: data.EmployeeID #.jpg" alt="#: EmployeeID #" /> |
| 84 | + </td> |
| 85 | + <td class="details"> |
| 86 | + <span class="name">#: FirstName# #: LastName# </span> |
| 87 | + <span class="title">Title: #: Title #</span> |
| 88 | + </td> |
| 89 | + <td class="country"> |
| 90 | + #: Country # |
| 91 | + </td> |
| 92 | + <td class="employeeID"> |
| 93 | + #: EmployeeID # |
| 94 | + </td> |
| 95 | + </tr> |
| 96 | + </script> |
| 97 | + |
| 98 | + <style> |
| 99 | + /* |
| 100 | + Use the DejaVu Sans font for display and embedding in the PDF file. |
| 101 | + The standard PDF fonts have no support for Unicode characters. |
| 102 | + */ |
| 103 | + .k-grid { |
| 104 | + font-family: "DejaVu Sans", "Arial", sans-serif; |
| 105 | + } |
| 106 | +
|
| 107 | + /* Hide the Grid header and pager during export */ |
| 108 | + .k-pdf-export .k-grid-toolbar, |
| 109 | + .k-pdf-export .k-pager-wrap |
| 110 | + { |
| 111 | + display: none; |
| 112 | + } |
| 113 | + </style> |
| 114 | + |
| 115 | + <script> |
| 116 | + // Import DejaVu Sans font for embedding |
| 117 | +
|
| 118 | + // NOTE: Only required if the Kendo UI stylesheets are loaded |
| 119 | + // from a different origin, e.g. cdn.kendostatic.com |
| 120 | + kendo.pdf.defineFont({ |
| 121 | + "DejaVu Sans" : "//kendo.cdn.telerik.com/2014.3.1314/styles/fonts/DejaVu/DejaVuSans.ttf", |
| 122 | + "DejaVu Sans|Bold" : "//kendo.cdn.telerik.com/2014.3.1314/styles/fonts/DejaVu/DejaVuSans-Bold.ttf", |
| 123 | + "DejaVu Sans|Bold|Italic" : "//kendo.cdn.telerik.com/2014.3.1314/styles/fonts/DejaVu/DejaVuSans-Oblique.ttf", |
| 124 | + "DejaVu Sans|Italic" : "//kendo.cdn.telerik.com/2014.3.1314/styles/fonts/DejaVu/DejaVuSans-Oblique.ttf" |
| 125 | + }); |
| 126 | + </script> |
| 127 | + |
| 128 | + <!-- Load Pako ZLIB library to enable PDF compression --> |
| 129 | + <script src="//kendo.cdn.telerik.com/2016.1.112/js/pako_deflate.min.js"></script> |
| 130 | + |
| 131 | + <script> |
| 132 | + $("#grid").kendoGrid({ |
| 133 | + toolbar: ["pdf"], |
| 134 | + pdf: { |
| 135 | + allPages: true, |
| 136 | + fileName: "Kendo UI Grid Export.pdf", |
| 137 | + proxyURL: "//demos.telerik.com/kendo-ui/service/export" |
| 138 | + }, |
| 139 | + toolbar: kendo.template($("#template").html()), |
| 140 | + dataSource: { |
| 141 | + type: "odata", |
| 142 | + transport: { |
| 143 | + read: { |
| 144 | + url: "//demos.telerik.com/kendo-ui/service/Northwind.svc/Employees", |
| 145 | + } |
| 146 | + }, |
| 147 | + pageSize: 5 |
| 148 | + }, |
| 149 | + columns: [ |
| 150 | + { title: "Photo", width: 140 }, |
| 151 | + { title: "Details", width: 350 }, |
| 152 | + { title: "Country" }, |
| 153 | + { title: "EmployeeID" } |
| 154 | + ], |
| 155 | + rowTemplate: kendo.template($("#rowTemplate").html()), |
| 156 | + altRowTemplate: kendo.template($("#altRowTemplate").html()), |
| 157 | + height: 500, |
| 158 | + scrollable: true, |
| 159 | + pageable: true |
| 160 | + }); |
| 161 | + </script> |
| 162 | + <style> |
| 163 | + .employeeID, |
| 164 | + .country { |
| 165 | + font-size: 50px; |
| 166 | + font-weight: bold; |
| 167 | + color: #898989; |
| 168 | + } |
| 169 | + .name { |
| 170 | + display: block; |
| 171 | + font-size: 1.6em; |
| 172 | + } |
| 173 | + .title { |
| 174 | + display: block; |
| 175 | + padding-top: 1.6em; |
| 176 | + } |
| 177 | + td.photo, .employeeID { |
| 178 | + text-align: center; |
| 179 | + } |
| 180 | + .k-grid-header .k-header { |
| 181 | + padding: 10px 20px; |
| 182 | + } |
| 183 | + .k-grid tr { |
| 184 | + background: -moz-linear-gradient(top, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.15) 100%); |
| 185 | + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.05)), color-stop(100%,rgba(0,0,0,0.15))); |
| 186 | + background: -webkit-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0.15) 100%); |
| 187 | + background: -o-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0.15) 100%); |
| 188 | + background: -ms-linear-gradient(top, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0.15) 100%); |
| 189 | + background: linear-gradient(to bottom, rgba(0,0,0,0.05) 0%,rgba(0,0,0,0.15) 100%); |
| 190 | + padding: 20px; |
| 191 | + } |
| 192 | + .k-grid tr.k-alt { |
| 193 | + background: -moz-linear-gradient(top, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.1) 100%); |
| 194 | + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(0,0,0,0.2)), color-stop(100%,rgba(0,0,0,0.1))); |
| 195 | + background: -webkit-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(0,0,0,0.1) 100%); |
| 196 | + background: -o-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(0,0,0,0.1) 100%); |
| 197 | + background: -ms-linear-gradient(top, rgba(0,0,0,0.2) 0%,rgba(0,0,0,0.1) 100%); |
| 198 | + background: linear-gradient(to bottom, rgba(0,0,0,0.2) 0%,rgba(0,0,0,0.1) 100%); |
| 199 | + } |
| 200 | + </style> |
| 201 | +</div> |
| 202 | +``` |
| 203 | + |
| 204 | +## See Also |
| 205 | + |
| 206 | +* [Kendo UI Grid PDF Export Overview.](https://docs.telerik.com/kendo-ui/controls/data-management/grid/pdf-export) |
0 commit comments