Closed larswaechter closed 1 year ago
An fillEmpty option might be useful for dynamically filling empty values.
fillEmpty
An example
const data = [ { firstname: 'Homer', lastname: 'Simpson', age: 39 }, { firstname: 'Marge', lastname: '', age: 36 }, { firstname: 'Bart', lastname: 'Simpson', age: 10 }, { firstname: 'Lisa', lastname: undefined, age: 8 }, { firstname: 'Maggie', lastname: null, age: 1 } ]; const table = new Table(data, { body: { fillEmpty: { lastname: (row) => 'Simpson' } } }); table.print();
Output:
firstname lastname age ================================ Homer Simpson 39 Marge Simpson 36 Bart Simpson 10 Lisa Simpson 8 Maggie Simpson 1
The method getDataCell should provide the filled value as well:
getDataCell
console.log(table.getDataCell(1, 'lastname')); // Simpson
An
fillEmpty
option might be useful for dynamically filling empty values.An example
Output:
The method
getDataCell
should provide the filled value as well: