5

I want to format values before exporting them to CSV. For this, I use the processCellCallback as shown in the Code sample. When I include the Callback, I get empty strings instead of cell value for every cell in my ag-grid. For this, I followed the example on the ag-grid Site https://www.ag-grid.com/javascript-grid-export/ and the StackOverflow article Ag-grid angular format data before exporting

For debugging purpose I commented everything out except the return and included a console.log

The Cell Value is written in the log, but my export CSV has only empty columns. I remove the processCellCallback in the params the value are properly exported.

ExportToCsv(gridApi: any, exportFileName: string){
    var params = {
      fileName: exportFileName
      ,columnSeparator: ';'
      ,processCellCallback: (params) => {this.processCells(params)}
    }
    gridApi.exportDataAsCsv(params);
  }
  processCells(params: any) {
    console.log(params.value);
    return params.value;
  }

1 Answer 1

6

processCellCallback must return a string. However in your code, the anonymous function returns nothing.

Change:

processCellCallback: (params) => {this.processCells(params)}

to

processCellCallback: (params) => this.processCells(params)

or for simplicity:

processCellCallback: this.processCells
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.