TreeGrid Printing
13 Feb 20183 minutes to read
TreeGrid provides support to print the contents. To print the TreeGrid the print toolbar item must be added to the toolbarItems
property. The below code example shows how to enable print in TreeGrid.
<div id="TreeGridContainer"></div>
<script type="text/javascript">
$("#TreeGridContainer").ejTreeGrid({
toolbarSettings: {
showToolbar: true,
toolbarItems: [
ej.TreeGrid.ToolbarItems.Print
]
},
})
The print preview window will be opened by clicking on this toolbar icon.
Print Mode
It is possible to set the printMode
in the pageSettings
property to give printing preference, as to print current page alone or all the pages in case of paging enabled in TreeGrid. The following code example explains this.
<div id="TreeGridContainer"></div>
<script type="text/javascript">
$("#TreeGridContainer").ejTreeGrid({
toolbarSettings: {
showToolbar: true,
toolbarItems: [
ej.TreeGrid.ToolbarItems.Print
]
},
allowPaging: true,
pageSettings: {
printMode: ej.TreeGrid.PrintMode.CurrentPage
},
})
In this case only the visible records in the current page will be send to printing.
beforePrint Event
The beforePrint
event will be triggered once after printing initiated in TreeGrid. This event contains the TreeGrid element which is going to be printing. The following code explains this.
<div id="TreeGridContainer"></div>
<script type="text/javascript">
$("#TreeGridContainer").ejTreeGrid({
toolbarSettings: {
showToolbar: true,
toolbarItems: [
ej.TreeGrid.ToolbarItems.Print
]
},
beforePrint: function(args) {
// will be triggered before printing the TreeGrid
},
})