数据表渲染没有被击中

时间:2017-11-09 21:09:38

标签: jquery ajax datatables

 $("[data-manifest-table]").DataTable({
        "processing": true,
        "serverSide": true,
        ajax: {
            url: "LoadManifestData",
            type: "POST",
            data: { FilterItem: new FilterItem($("[data-statuses]").val(), $("[data-products]").val(), $("[data-field-reps]").val(), $("[data-states]").val(), $("[data-clients]").val()), __RequestVerificationToken: ReturnAntiForgeryToken() },
            error: function (jqXHR, textStatus, errorThrown) {
                alert("woot");
            }

        },
        "columns": [
            { "data": "ClientID" },
            { "data": "TransNo" },
            { "data": "Assigned" },
            { "data": "Due" },
            { "data": "DebtorBusiness" },
            { "data": "Address" },
            { "data": "Appt" },
            { "data": "FieldRep" },
        ],
        "render": function (data, type, row) {
            debugger
            $("td:eq(6)", row).html("<p>hdfg</p>")
        },
    });

我有这个数据表初始化器,我试图点击渲染功能,因为我想修改数据。但是渲染功能不会受到影响。谁知道为什么?

1 个答案:

答案 0 :(得分:1)

它应该是columns选项的子属性。

"columns": [
    { "data": "ClientID" },
    { "data": "TransNo" },
    { "data": "Assigned" },
    { "data": "Due" },
    { "data": "DebtorBusiness" },
    { "data": "Address" },
    { 
        "data": "Appt", 
        "render": function(data, type, full, meta){
           if(type === 'display'){
               data = "<p>hdfg</p>";
           }

           return data;
         }
    },
    { "data": "FieldRep" }
],

有关详细信息,请参阅columns.render