TreeGrid Printing

29 Jun 20181 minute to read

TreeGrid provides support to print the contents. To print the TreeGrid the print toolbar item must be added to ToolbarSettings.ToolbarItems property. The below code example shows how to enable print in TreeGrid.

  • JS
  • <ej:TreeGrid runat="server" ID="TreeGrid">
        <ToolbarSettings ShowToolbar="true" ToolbarItems="Print"></ToolbarSettings>

    The below screen shot shows TreeGrid with printing enabled.

    The print preview window will be opened by clicking on this toolbar icon.

    It is possible to set the printMode in 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.

  • JS
  • <ej:TreeGrid runat="server" ID="TreeGrid" AllowPaging="true">
         <PageSettings PrintMode="CurrentPage" /> 
         <ToolbarSettings ShowToolbar="true" ToolbarItems="print"></ToolbarSettings>

    In this case only the visible records in the current page will be send to printing.

    BeforePrint Event

    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.

  • JS
  • <ej:TreeGrid runat="server" ID="TreeGrid" BeforePrint="beforePrint">
        <ToolbarSettings ShowToolbar="true" ToolbarItems="Print"></ToolbarSettings>
        function beforePrint(args) {
            //will be triggered before printing the TreeGrid

    Click here to view the online demo sample Printing.