Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AG-Grid skip column on export to CSV

I have a column in a table which has only buttons in it. The button is a download button. I dont what this column to be exported when i click on export to csv. Can this be done?

like image 484
rkiyer Avatar asked Jun 07 '18 07:06

rkiyer


3 Answers

I know this is an old question but this is what worked for me:

exportToExcel() {
var params = {
    columnKeys: ['FIELDA', 'FIELDB', 'FIELDC']
};
this.gridApi.exportDataAsCsv(params);
}

You get the fields from the ColumnDef

like image 152
Jett Avatar answered Sep 26 '22 02:09

Jett


You can specify which columns data you want in export while calling gridApi.exportDataAsCsv(params). You can mention that in columnKeys parameter.

params.columnKeys = ["country", "bronze"];
this.gridApi.exportDataAsCsv(params);

Reference: ag-grid: CSV export

Check the result - if you check Specify Columns checkbox, only the above mentioned columns will be there in the CSV.

like image 41
Paritosh Avatar answered Sep 24 '22 02:09

Paritosh


Internally it search for colId of a particular column. AG Grid adds '_1' to every field as a unique colId.

Try this , It will work.

Under ColDefs , if your field name is : FieldA , FieldB.

const params = {
columnKeys: ['FieldA_1','FieldB_1'];
};
like image 33
gurpreet singh Avatar answered Sep 26 '22 02:09

gurpreet singh