需要调用ajax,但不应重新加载Datatable

时间:2018-07-18 12:39:04

标签: javascript jquery datatables

场景:

我有一个使用ajax调用的数据表,我需要在不重新加载数据表的情况下调用该ajax调用。我知道这个要求很奇怪,但这就是我所需要的。

当前代码:

findertable = $('#finder-product').DataTable({
"lengthMenu": [10, 25, 50, 100],
"processing": true,
"serverSide": true,
"info": true,
"stateSave": true,
"bFilter": false,
"searching": true,
"drawCallback": function (settings, json) {
    $('[data-toggle="tooltip"]').tooltip();
},
"ajax": {
    "url": "@Url.Action("GetSpecFindergrid", "SpecFinder")",
    "data": function (d) {
        d.selectedGroups = $('#advanced-search-contact').val();
        d.mode = findertable_mode;
    },
    "type": "POST"
},
"language": {
    "paginate": {
        "previous": "<<",
        "next": ">>"
    },
    "zeroRecords": "No matching records found",
    "info": "Showing _START_ to _END_ of _TOTAL_",
    "lengthMenu": "Show _MENU_",
    "search": "",
    "searchPlaceholder": "Search...",
    "processing": '<div id="pageloader" class="spinner"><div class="double-bounce1"></div><div class="double-bounce2"></div></div>'
},
"columns": [
                { "data": "Title", "orderable": true, "searchable": true },
                { "data": "LineOfBusiness", "orderable": true, "searchable": true },
                { "data": "DSCLocation", "orderable": true, "searchable": true },
                { "data": "Vendor", "orderable": true, "searchable": true },
                { "data": "Plant", "orderable": true, "searchable": true },
                { "data": "Status", "orderable": true, "searchable": true },
                { "data": "Contact", "orderable": true, "searchable": true }
],
"order": [[0, "asc"]],
createdRow: function (row, data, dataIndex) {
    $(row).find('td:eq(1)').attr('title', data["Title"]);
    $(row).find('td:eq(1)').attr('data-toggle', "tooltip");
}
});

当前我正在使用

findertable.ajax.reload();

但这会调用url,但数据表正在重新加载。无论如何,我应该调用url,但不应该重新加载数据表。并且应该使用可查找的Ajax网址。

0 个答案:

没有答案