Basic Question, how to inserting named columns with object
Basic Question, how to inserting named columns with object
Hi,
I want to take a javascript object with named columns...
Eg
var search_table = $('table#search.dataTable').dataTable( {
"columns": [
{ "title": "Contact" },
{ "title": "Account"},
{ "title": "Street"},
{ "title": "City"},
{ "title": "PostCode"}
]
});
And then make a call to the api to insert a row with named data...
var data = {'Contact':'Pearson','Account':'Unified Holdings Plc','Street':'3 Corporate Road','City':'York','Postcode':'LS43PR'};
search_table.api().add.row(data);
I can't get the assignment to a named column to work. I get the cryptic error "Requested unknown parameter 0 for row 0".
(As an aside) I can however populate the table with a list. Eg
var data = ['Pearson','Unified Holdings Plc','3 Corporate Road','York','LS43PR'];
search_table.api().add.row(data);
How can I set up my table so object passing, with named columns, works?
I'd expect a call to .api().columns() to describe the names on the columns, instead I just get an array of equal key/value pairs. ([0:0,1:1,2:2 ...])
Seems like a noob question, so apologies in advance.
ETA: Using DataTables 1.10.2