Skip to content

Commit

Permalink
Fixed #2209 - Extend exportFunction (csv) with the whole record
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 8, 2021
1 parent 85b666b commit 62be178
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/datatable/DataTable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ interface DataTableUnselectParams extends DataTableSelectParams { }
interface DataTableExportFunctionParams {
data: any;
field: string;
rowData: any;
column: Column
}

interface DataTableColReorderParams {
Expand Down
2 changes: 1 addition & 1 deletion src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ export class DataTable extends Component {
let cellData = ObjectUtils.resolveFieldData(record, field);

if (cellData != null) {
cellData = this.props.exportFunction ? this.props.exportFunction({ data: cellData, field }) : String(cellData).replace(/"/g, '""');
cellData = this.props.exportFunction ? this.props.exportFunction({ data: cellData, field, rowData: record, column }) : String(cellData).replace(/"/g, '""');
}
else
cellData = '';
Expand Down
4 changes: 3 additions & 1 deletion src/showcase/datatable/DataTableDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3328,7 +3328,9 @@ export const DataTableStateDemo = () => {
<td>null</td>
<td>A function to implement custom export. Need to return string value. <br />
event.data: Field data. <br />
event.rows: Column field.</td>
event.field: Column field.
event.rowData: Row data.
event.column: Column.</td>
</tr>
<tr>
<td>expandableRowGroups</td>
Expand Down

0 comments on commit 62be178

Please sign in to comment.