How do I update a row in the datatable with jquery? [closed]

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 too with jquery and the code below is not working. What am I doing wrong below?

var NovaLinha = [usuario,email,senha,ativo,acao];
$('#tabela').DataTable().row('#'+id).data(NovaLinha).draw();
    
asked by anonymous 22.02.2015 / 19:19

1 answer

1

Use the fnUpdate method to do this.

  

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

Example:

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

Demonstration in JSFiddle

    
22.02.2015 / 21:16