using $('#sort_table').dataTable().fnDraw(true); datatable content not updated

using $('#sort_table').dataTable().fnDraw(true); datatable content not updated

sayedfarhan1sayedfarhan1 Posts: 8Questions: 6Answers: 0

i have a edit button in repeater control. on editing and saving the value in repeater control is not refreshed.

on success of saving i am calling Function LoadRepeater() which bring a refreshed data from database and replaced with old data in repeater control.

function LoadRepeater() {

    var content = ""
    $.ajax({
        type: "POST",
        url: "wfPARM.aspx/BindRepeter",
        data: '{}',
        contentType: "application/json; charset=utf-8",
        success: function (msg) {
            for (var i = 0; i < msg.d.length; i++) {
                content += '<tr>';
                content += '<td style="padding-left:0%">' + msg.d[i].ParmType + '</td>';
                content += '<td style="padding-left:0%">' + msg.d[i].ParmCode + '</td>';

                content += '<td><button type="button" class="DisplayData fa fa-edit" title="Edit" txt=' + msg.d[i].ParmCode + ' val=' + msg.d[i].ParmType + ' style="background-color:transparent;border:none;"></button>  </td>';
                content += '</tr>';
            }
            $('#sort_table').find('tbody').empty().append(content);
            $('#sort_table').dataTable().fnDraw(true);               

        }
    });
}

Answers

  • sayedfarhan1sayedfarhan1 Posts: 8Questions: 6Answers: 0

    When i am using
    $('#sort_table').dataTable().fnDraw();
    repeater is refreshed but pagination,filter,and sorting is loss

  • larsonatorlarsonator Posts: 54Questions: 4Answers: 2
    edited July 2014

    are you getting any error's in your console?

    It looks liked you are manually removing all the content of the table, and manually putting it back in again, instead of letting the plugin do it, which would create a miss match with the data stored in the plugin, and that which is on the page.

    It is possible, that calling the fnDraw function is overriding what you have manually entered with the data stored in the plugin from it's last ajax call.

    Try and have a look at this API : http://datatables.net/reference/api/ajax.url%28%29.load%28%29

    if you are simply calling a new url, this is function you want, how ever if you are simply wanting the newly added records just entered which can be sourced from the same url, check out this API: http://datatables.net/reference/api/ajax.reload%28%29

This discussion has been closed.