Andrew
Andrew

Reputation: 780

Datatables render is not being hit

 $("[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>")
        },
    });

I have this data tables initialiser and I'm trying to hit the render function becasue I'd like to modify the data. However the render function doesn't get hit. Anyone know why?

Upvotes: 1

Views: 1898

Answers (1)

Gyrocode.com
Gyrocode.com

Reputation: 58930

It should be sub-property for columns option.

"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" }
],

See columns.render for more information.

Upvotes: 2

Related Questions