Set Cell Value before print

Hi,

On my grid, I hide 2 columns when printing using toolbar click event en print complete event to show the columns again when print completes.

I need to set the value of a third column to be a blank value. The grid's datasource sets the value of this column (let's call it OrderQty) to 0 from local data. When printing, this value must be set to null for the printing action. Once print completes, the value must be reset back to the original value from the data source.

Is this possible?


1 Reply 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team November 3, 2021 12:36 PM UTC

Hi Eddie, 

Greetings from Syncfusion support. 

  Based on your query, you want to hide two columns before print and after print is completed you want to show the columns again. 

  Your requirement can be achieved using the `BeforePrint` method of the EJ2 grid. Where you can customize the datasource and columns as per your requirement. 

Please refer the below code example. 



function beforePrint(args) { 
 
// here you need to pass your dataSource and columns what you need to print  
        var grid = document.getElementById('Grid').ej2_instances[0]; 
        args.element.ej2_instances[0].setProperties({ 
            dataSource: grid.dataSource.slice(0, 4), columns: [ 
                { field: 'CustomerID', headerText: 'Customer ID', textAlign: 'Right', width: 125 }, 
                { field: 'EmployeeID', headerText: 'Employee ID', width: 180 }, 
                { field: 'ShipCity', headerText: 'Ship City', width: 110 } 
            ] 
 
        }) 
    } 






Please get back to us for further details. 

Regards, 
Joseph I 


Marked as answer
Loader.
Up arrow icon