ajax missing keys handler
ajax missing keys handler
When I pull back the JSON for my table via the built-in datatables ajax function, not every row is going to have every key. I need a handler that says: "If a key is missing for a particular row, put an empty string in that cell".
It is not obvious how to do this.
Instead, the end user gets alerts with cryptic warnings. After clicking 'OK' through them, the table appears as expected.
ie, when my data looks like this:
rows.data = [
{col1: valA, col2: valB, col3: valC},
{col2: valD, col3: valE}
]
I want it to put an empty string in col1, row 2 when it renders the table.
Answers
To answer my own question...
It looks like if I put a { "defaultContent": "" } on the columns property, it will set an empty string when the key is missing.