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

user3214546 picture user3214546 · Jan 7, 2015 · Viewed 7.2k times · Source

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?

Answer

lmyers picture lmyers · Jan 7, 2015

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