I want to set data in more than one datatable with a special ajax, but Alert Error =DataTables warn

I want to set data in more than one datatable with a special ajax, but Alert Error =DataTables warn

ismaillakdassismaillakdass Posts: 1Questions: 1Answers: 0
edited March 3 in Free community support
var tableFragmentation = $('#tableFragmentation');
var containerGroupId = "";
var requestData;
$(document).ready(function () {
    requestData = {
        draw: 1,
        start: 0,
        length: 10,
        search: {
            value: "",
            regex: false
        },
        order: [
            {
                column: 0,
                dir: ""
            }
        ]
    };

    $.ajax({
        url: '/PostPcrUnits/FragmentationListDTJs',
        type: 'POST',
        dataType: 'json',
        data: requestData,
        success: function (response) {
            //debugger;            
            var dataSet = response.data;
            initFragmentationTable(dataSet);
        }
    });
       

});

// #region Datatables Pcr - Pcr Kabul Listesi
function initFragmentationTable(dataSet) {
    tableFragmentation.DataTable({
        processing: true,
        serverSide: true,
        ordering: true,
        filter: true,
        fixedColumns: { left: 1 }, //işlemler kolonu sabitleniyor.
        scrollY: '400px',
        scrollX: true,
        autoWidth: true,
        language: { url: '//cdn.datatables.net/plug-ins/1.10.22/i18n/Turkish.json' },
        dom: "<'row'<'col-sm-12 col-md-6'B><'col-sm-12 col-md-6'f>>" +
            "<'row'<'col-sm-12'tr>>" +
            "<'row'<'col-sm-12 col-md-3'l><'col-sm-12 col-md-3'i><'col-sm-12 col-md-6'p>>",
        buttons: [
            { extend: 'excel', text: 'Excel indir', },
            { extend: 'colvis', text: 'Goster/Gizle', },
        ],
        data: dataSet,
        columns: [
            {
                data: 'id',
                render: function (data, type, row) {
                    var islem = "";
                    if (row.btnAddBarcodeFragmentation) {
                        islem += '<a data-id=' + data + ' id="btnSetBarcode" title="Onayla" class="btn btn-sm btn-icon item-edit"><i class="text-success ti ti-bookmarks"></i></a>';
                    }
                    return '<a data-id=' + data + ' id="btnGetPlate" title="Batch Icerik" class="btn btn-sm btn-icon item-edit"><i class="text-info ti ti-search"></i></a>' +
                        islem;
                }
            },
            { data: 'name' },
            {
                data: 'containerGroupType',
                render: function (data, type) {
                    var result;
                    data === 11 ? result = "Batch CT" : data === 2 ? result = "Troubleshoot" : result = "Tanımsız";
                    return result;
                }
            },
            { data: 'batchSize' },
            { data: 'tagName' },
            { data: 'createdDate', render: DataTable.render.datetime('DD-MM-YYYY HH:mm') },
            { data: 'createdUserId' },

        ],
        columnDefs: [
            { targets: 0, orderable: false, searchable: false, width: '100' },
        ]
    });
};
// #endregion

Edit by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

Answers

  • kthorngrenkthorngren Posts: 20,347Questions: 26Answers: 4,776
    edited March 3

    You have serverSide: true set but are using data instead of ajax. That will cause errors. To utilize server side processing you will need to use ajax instead of data.

    I see you are trying to emulate the the SSP parameters with the jQuery ajax() sent to the server. Why are you doing this instead of using the ajax option?

    What errors do you get?

    Kevin

Sign In or Register to comment.