2017-02-08 93 views
0

我想通過數據表訪問不同列的屬性。Datatables ColumnDefs訪問不同的列數據?

例如:

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的例子嗎?

回答

0

「full」將包含行的所有列值。例如

{ 
"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>'; 
} 
},