Datatables ColumnDefs访问不同的列数据?

时间:2017-02-08 21:47:42

标签: jquery datatables

我想从具有数据表的不同列访问属性。

例如:

 columnDefs: [
             {
                "targets": 4,
                "data": "default_price_with_discount",
                "sClass": "text-center",
                "render": function (data, type, full, meta) {
                    return '<strong>' + data + '</strong>';
                }
            },
            {
                "targets": 5,
                "data": "default_bonus",
                "sClass": "text-center",
                "render": function (data, type, full, meta) {

                    // how can i acccess here column 4?

                    return '<strong>' + data + '</strong>';

                }
            },

有关如何从第5列访问第4列的任何想法吗?

1 个答案:

答案 0 :(得分:1)

“full”将包含row的所有列值。例如

{
"targets": 5,
"data": "default_bonus",
"sClass": "text-center",
"render": function (data, type, full, meta) {
var column4Value = full.default_price_with_discount;
return '<strong>'  + data + '</strong>';
}
},