2

I have one partial view, onload which is loading in table tbody perfectly. But after that in the same page onchange dropdown when i m calling the same partial view it is binding but it is showing this error. I am using bootstrap DataTable.

DataTables warning: table id=DataTables_Table_0 - Cannot reinitialise DataTable.
For more information about this error, please see http://datatables.net/tn/3

Here what i have done. This is the onload function.

    $(document).ready(function () {
    var collectoinPointUrl = ROOT + "Dietitian/PatientDietList_Pv"
    $.ajax({
        url: collectoinPointUrl,
        data: { WardId: 0 },
        type: "GET",
        success: function (result) {
            $('#LoadPatientList').html(result);
        }
    });
});

And this is onchange function

    $('#SearchPatient').click(function () {
    var WardId = $('#Wardid option:selected').val();
    var collectoinPointUrl = ROOT + "Dietitian/PatientDietList_Pv"
    $.ajax({
        url: collectoinPointUrl,
        data: { WardId: WardId },
        type: "GET",
        success: function (result) {
            //if (!$.fn.DataTable.isDataTable('#patientdiettable')) {
            //$('.dataTable-length').DataTable({
            //    destroy: true,
            //}).clear().draw();
            //}
            $('#LoadPatientList').html(result);
        }
    });
});

I tried to destroy DataTable and bind again .still no luck. Any help will be appreciated. Thanks in Advance.

Gyrocode.com
  • 57,606
  • 14
  • 150
  • 185
Tonmoy Saha
  • 652
  • 1
  • 5
  • 13
  • There's a link in the error which tells you why this is happening and *exactly* what need to do to resolve it ...? – Rory McCrossan Dec 15 '17 at 09:53
  • i know what exactly the error is . but i m not initialising DataTable manually anywhere. Inside Partialview i m declared all the js files. I am asking how can i stop initilize DataTable when partial view is loading second time. – Tonmoy Saha Dec 15 '17 at 09:58

0 Answers0