ag-grid angular 5 export hidde,列

时间:2018-08-08 09:12:39

标签: angular5 ag-grid

我正在为我的角度5的ag-grid列开发导出功能

这是我的专栏代码:

columnDefs = [{  
  headerName:'',
  field:'',
  pinned:true,
  headerCheckboxSelection:true,
  headerCheckboxSelectionFilteredOnly:true,
  width:42,
  checkboxSelection:true
}, {  
  headerName:'Actions',
  field:'_id.$oid',
  cellRenderer:'viewModalRenderer',
  pinned:true
}, {  
  headerName:'Status',
  field:'status'
}, {  
  headerName:'Category',
  field:'category',
  cellRenderer:'viewCetegoryRenderer',
  width:120,
  editable:true,
  hide:true
}, {  
  headerName:'Created',
  field:'created',
  editable:true,
  filter:'agDateColumnFilter'
}, {  
  headerName:'Price',
  field:'price',
  filter:'agNumberColumnFilter',
  width:120,
  editable:true
}];

我正在调用此函数以导出

onBtnExport() {
  let params = {}
  this.gridApi.exportDataAsCsv(params);
}

如何在导出中包括标记为hide:true的Category列?

1 个答案:

答案 0 :(得分:0)

尝试以下代码:

   exportCsv() {       
    var excelParams = {
        columnKeys: ['firstName', 'middleName','lastName', 'dob'],
        allColumns: false,
        fileName: 'Student List.csv',
        skipHeader: false,
        customHeader: 'Student List' + '\n',
        customFooter: '\n \n Total No.Of Students :' + this.gridOptions.api.getModel().getRowCount() + ' \n'
    }
    this.gridOptions.api.exportDataAsCsv(excelParams);
}

定义要在columnKeys中显示的列