How do I update a datatable line with jquery?

Asked

Viewed 1,152 times

3

I have the following code working to add a row to the table dynamically

var NovaLinha = [usuario,email,senha,ativo,acao];
NovaLinha.id = retorno;
$('#tabela').DataTable().row.add(NovaLinha).draw();

now I want to change it also with jquery and the code below is not working. What I am doing wrong below?

var NovaLinha = [usuario,email,senha,ativo,acao];
$('#tabela').DataTable().row('#'+id).data(NovaLinha).draw();

1 answer

1

Use the method fnUpdate for that reason.

Update a cell or table row - this method will accept a unique value to update the cell, an array of values with a element for each column or object in the same format as the source of original data.

Example:

var tbl = $('#tabela').dataTable({ ... })
tbl.fnUpdate(['Baz', '[email protected]', 'pass', 'no'], 1);

Demonstration in Jsfiddle

Browser other questions tagged

You are not signed in. Login or sign up in order to post.