javascriptangularjsng-gridangular-ui-gridpdfmake

How can I remove some columns in pdf export in angular js ui Grid


I am using Angular JS ui Grid

http://ui-grid.info/docs/#/tutorial/312_exporting_data_complex

My requirement is that I want to show e.g. 5 columns, but when I export PDF, I don't want to export certain columns like username.

How can I do that?


Solution

  • There is a gridOption to do exactly that: exporterSuppressColumns

    I edited the plunker from the UI Grid documentation to demonstrate hiding the "Gender" column in the exported PDF: http://plnkr.co/edit/89ZVlPZcQbHYzgX5l4yq?p=preview

    Now whether you select export "all" or export "visible", you will never see the gender column in the output.

      $scope.gridOptions = {
    columnDefs: [
      { field: 'name',visible:true },
      { field: 'gender', cellFilter: 'mapGender', exporterPdfAlign: 'right', visible:true, enableHiding: true },
      { field: 'company', visible: false }
    ],
    exporterSuppressColumns: [ 'gender' ],
    

    The documentation is here: http://ui-grid.info/docs/#/api/ui.grid.exporter.api:GridOptions