How do I update the data of one row without drawing?

How do I update the data of one row without drawing?

JanurajJanuraj Posts: 85Questions: 18Answers: 0

var table =$('#profile-table').DataTable();
table.row( row ).data( data ).draw();

When i update one row using "table.row( row ).data( data ).draw();" the data is updated and again the table is drawn with previous values

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Sounds like you have server side processing enabled. With server side processing each draw() API call will send an ajax request to the server to fetch the current page's data.

    You could remove the .draw(), ie table.row( row ).data( data );, and have the table show the changed information. However sorting, etc won't be updated unless you call draw().

    In order to keep the updated row data with server side processing you will need to use an jQuery Ajax request to send the data to the server and the server script will need to update your Database.

    Kevin

  • JanurajJanuraj Posts: 85Questions: 18Answers: 0

    Thanks @kthorngren for the clarifying this.

    But the solution which u provided is partial for my case.

    The other problem is i am using "createdCell" to render the columns. But when i update the row using "table.row( row ).data( data )", it is actually taking the data of that attr, but not printing the data as i had in. createdCell.
    How to render the desired value using createdCell and table.row( row ).data( data )

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    The columns.createdCell docs state this:

    This is a callback function that is executed whenever a cell is created (Ajax source, etc) or read from a DOM source.

    Basically it runs only once. For data that changes use rowCallback.

    Kevin

This discussion has been closed.