Redraw table

Redraw table

Crowz4kCrowz4k Posts: 1Questions: 1Answers: 0
edited June 2017 in Free community support

I need to redraw table after some edit but it is now working here is my code what i am doing wrong?

function Success(response)

{

$("#info").hide();
$("#warning").hide();
if (!response.responseJson.isSuccess) {
    $("#messageError").html(response.responseJson.Message);
    $("#warning").show();

} else if (response.isEdit) {
    var trCurrent = $("#" + response.model.Id);
    var table = $("#example1").DataTable();
    var rowdata = table.row(trCurrent);
    rowdata.data()[0] = response.model.FirstName;
    table.draw();


    $("#messageInfo").html(response.responseJson.Message);
    $("#info").show();
    setTimeout(function () {
            $("#Close").click();
        },
        1500);
} else {
    var modelData = response.model;
    ajaxAddNewRow(modelData,
        function () {
            $("#messageInfo").html(response.responseJson.Message);
            $("#info").show();
            setTimeout(function () {
                    $("#Close").click();
                },
                1500);
        });
}

}

To be clear table wont update,new value wont show

Answers

  • HPBHPB Posts: 73Questions: 2Answers: 18
    edited June 2017

    Are you overriding the success function from the ajax option in DataTables?

    Quote from ajax

    success - Must not be overridden as it is used internally in DataTables. To manipulate / transform the data returned by the server use ajax.dataSrc (above), or use ajax as a function (below).

    As per the forum rules please provide a testcase showing the issue.
    We can help you a lot better if we can look at actual code that is causing the issue.

  • allanallan Posts: 61,821Questions: 1Answers: 10,127 Site admin

    rowdata.data()[0] = response.model.FirstName;
    table.draw();

    Since you are setting the data object directly rather than using the API to set the value, you need to tell DataTables that the value has changed. The row().invalidate() method can be used for that.

    Allan

This discussion has been closed.