Question on retrieve option in datatable

Question on retrieve option in datatable

yu yen kanyu yen kan Posts: 65Questions: 31Answers: 0

with retrieve: true in datatable

                $.ajax({
                    url: ".....",
                    type: 'GET',
                    success: function (response) {
                        try {
                            var json = JSON.parse(response);
                            var table = $("#table").DataTable({
                                retrieve: true,
                                data: json.data
                            });
                       }catch{
                       }
                   }
               });

everytime I retrieve data from ajax, the table data is not update, is that it working like that?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Hi,

    The retrieve documentation states:

    Retrieve the DataTables object for the given selector. Note that if the table has already been initialised, this parameter will cause DataTables to simply return the object that has already been set up - it will not take account of any changes you might have made to the initialisation object passed to DataTables (setting this parameter to true is an acknowledgement that you understand this!).

    That's what is happening here!

    Use clear() to clear the old data and rows.add() to add the new if the table already exists.

    Allan

This discussion has been closed.