clear dynatable records before new update

1.4k Views Asked by At

I am using dynatable plugin. I want to know how do I clear(remove all records) the table before I insert new records in table. Currently, the table is appending new records to the previous records.

My code:
response = $.parseJSON(data);

                var dynatable = $('#printIDs').dynatable({
                    dataset : {
                        records : response
                    }
                }).data('dynatable');

                 dynatable.settings.dataset.originalRecords = response;
                 dynatable.process();
1

There are 1 best solutions below

0
On

I had some trouble with this as well. My final code ended up looking like:

var getAuditRecords = function (requestUrl) {
    $.ajax({
        url: requestUrl,
        dataType: "json",
    }).done(function (response) {
        var dynatable = $('#auditTable').dynatable({
            dataset: {
                records: response
            }
        }).data('dynatable');

        dynatable.settings.dataset.originalRecords = response;
        dynatable.process();
    });
};