row.add not work
row.add not work
Wilmer30
Posts: 33Questions: 10Answers: 1
I have the following code:
success: function(msg) {
var dat = $.parseJSON(msg);
console.log(dat);
if(dat.msg == '1'){
table.row.add( [
dat.data.id_documento,
dat.data.identificador,
dat.data.nombre_documento,
dat.data.promotor,
dat.data.estado,
dat.data.accion
] ).draw( false );
console.log(dat.data.id_documento);
where console print value -> 19.
DataTables warning: table id=datatable - Requested unknown parameter 'id_documento' for row 18, column 0.
i have no idea why that warning.
This question has accepted answers - jump to:
This discussion has been closed.
Answers
IIRC your Datatables is using object based data, ie, you used
columns.data
. You are trying to add an array not an object. The format forrow.add()
needs to be the same as your original data.Kevin
Yes, I use
columns.data
,the data is similar in columns:
{"msg":"1","data":{"id_documento":"21","identificador":"asdasfd","nombre_documento":"asdfasdf","promotor":"Wilmer Hilaquita","estado":"Activo","accion":"moredata"}}
You should be able to simply use:
This should result in
{"id_documento":"21","identificador":"asdasfd","nombre_documento":"asdfasdf","promotor":"Wilmer Hilaquita","estado":"Activo","accion":"moredata"}
being added.Kevin
Thanks, it works fine, but I have a question, I previously loaded the data using
table.row.add([dat.data.column1,dat.data.column2,...]).draw(false);
why now it does not work ?, if I could clarify this doubt please.
Or if you have a link to verify the reference.
This doc explains the use of arrays and objects with datatables.
When this worked did you have
columns.data
defined?Kevin
Had not defined
columns.data
.