How to correctly configure nested data?
How to correctly configure nested data?
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.cobject structure you defined incolumns.dataor you can usecolumns.renderin the third column to appropriately display that column based on the existence ofa.b.cby using therowparameter.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.cthen 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===nullwould 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
defaultContentwill help. Checkout this updated example:http://live.datatables.net/goqihidi/1/edit
Kevin
Yeah, it does
. Thanks for the hint.
defaultContent: nulldoes 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).