How to correctly configure nested data?
How to correctly configure nested data?
eprozium
Posts: 9Questions: 3Answers: 0
Hi,
How to correctly configure nested data?
E.g. in the example here: http://live.datatables.net/gekamiqi/1/edit
row 1 and 4 are rendered correctly , but not 2 or 3 (commented out since will break the table) .
Thank you.
This discussion has been closed.
Answers
Either you need to pre-process the data so each row has the
a.b.c
object structure you defined incolumns.data
or you can usecolumns.render
in the third column to appropriately display that column based on the existence ofa.b.c
by using therow
parameter.Kevin
@kthorngren thank you for your help.
Whoaaa .This looks like a serious limitation: all serverside JSON serializers will simply render the data like in my example if values are null - nobody renders the entire null structure - because it's null, and it would be correct otherwise.
That would require for almost each column to write renderer for display, filter and sort - even if those are normal values, otherwise correctly rendered by DataTables if they weren't nested .
The point is if you are going to tell Datatables to look for an object
a.b.c
then that structure needs to be there. Can your server script not generate that structure for each row returned?Kevin
Thank you for the info. I understand that DataTables "expects" that, but compared to all other solutions I've seen, it's technically wrong: other code that relies on
a===null
would break if one would passa:{b:{c:null}}
instead.One could, but than all other components in the page would break. Also it's not a default behavior on any JSON serializer library I know, so one would need to write extra code .
Maybe using
defaultContent
will help. Checkout this updated example:http://live.datatables.net/goqihidi/1/edit
Kevin
Yeah, it does . Thanks for the hint.
defaultContent: null
does not seem to work, butdefaultContent: ''
seems to do it.Only CSV and Excel Export seems to be affected by this (but I can't make those buttons appear in the official JSBin in order to show it).