Search code examples
javascripttabulator

Tabulator Print the clicked row - Print PDF?


I am looking if there is any I can add a print button to tabulator row and when it is clicked it prints that particular row?

http://tabulator.info/docs/4.3/print

thanks


Solution

  • There is no built in functionality for this, but you could easily put something together to achieve this. This examples assumes that each row has a unique id field.

    You could use a custom formatter to create a Button Column, then use that to filter the table to just that row, then print the table, then clear the filter:

    //custom formatter definition
    var printIcon = function(cell, formatterParams, onRendered){ //plain text value
        return "<i class='fa fa-print'></i>";
    };
    
    //column definition in the columns array
    {formatter:printIcon, width:40, align:"center", cellClick:function(e, cell){ 
    
        //filter table to just this row
        table.Filter(function(data){
            return data.id == cell.getData().id;
        });
    
        //print the table
        table.print();
    
        //clear the filter
        table.clearFilter();
    }},