Open
Description
Currently within the source object/array get stringified. I propose mapping these to null
and then filtering columns in render
.
Original:
render() {
const { row, fields } = this.props;
return (
<tr onClick={() => this.handleOnClick(row)}>
{ this.renderCheckboxCell(row.id) }
{ fields.map(field => this.renderCell(field, row)) }
{ this.renderButtons(row) }
</tr>
);
}
// ...
renderCell(field, row) {
let value = row[field.name];
value = this.props.dataItemManipulator(field.name, value);
if (typeof value === 'object' || typeof value === 'array') {
value = JSON.stringify(value);
}
return (
<td key={`${row.id}_${field.name}`}>{ value }</td>
);
}
New:
render() {
const { row, fields } = this.props;
return (
<tr onClick={() => this.handleOnClick(row)}>
{ this.renderCheckboxCell(row.id) }
{ fields.map(field => this.renderCell(field, row)).filter(field => field) }
{ this.renderButtons(row) }
</tr>
);
}
// ...
renderCell(field, row) {
let value = row[field.name];
value = this.props.dataItemManipulator(field.name, value);
if (typeof value === 'object' || typeof value === 'array') {
return null;
}
return (
<td key={`${row.id}_${field.name}`}>{ value }</td>
);
}
Thoughts?
Metadata
Metadata
Assignees
Labels
No labels