Closed zoranlorkovic closed 4 years ago
Thanks @zoranlorkovic for the suggestion. Perhaps we also need to provide an option to overwrite the character used to separate key names as nested.time
can actually be a key for someone.
Released as v1.6.0. Let me know if there's any issue 👍
Hi good day, I just tried
example object: {
name: 'SSL Certificate',
stock: null,
price: 3650,
ProductCategory: {
name: 'All',
}
},
header = [
{ id: 'name', title: 'name' },
{ id: 'ProductCategory.name', title: 'category' },
{ id: 'price', title: 'price' },
{ id: 'stock', title: 'stock' },
];
but the category column always comes out empty.
Hi @kazeemOnis , you need to specify headerIdDelimiter: '.'
. I didn't want to make .
as a default value, as it had introduced a breaking change otherwise.
headerIdDelimiter
<string>
(optional)Default:
undefined
. Give this value to specify a path to a value in a nested object.
As often you need to get data from database and then export it in CSV, it would be very handy if we could put nested IDs in header object.
Example:
object = {name: Test, surname: Test, nested: {time: test}}
And our header object would look like:
header: [{id: 'name', title: 'First name' }, {id: 'surname', title: 'Last name'}, {id: 'nested.time', title:'My time'}]
Does this make sense?