我有一个具有以下结构的DataTable:
$('#table_1').DataTable(
{
"order": [[ 3, "asc" ]],
"processing": true,
"serverSide": true,
"ajax": "response/cases_main_server_side_processing.php",
columns: [
{
data: null,
className: "center",
defaultContent: '' ,
"orderable": false
},
{ data: "ID" },
{ data: "Status" },
{ data: "Sale Date" },
{ data: "Max Bid" },
{ data: "Zestimate" },
{
data: null,
className: "center",
defaultContent: 'Delta',
"orderable": false
}
],
"createdRow": function( row, data, dataIndex )
{
if(data["Max Bid"] == "-100")
{
row.cells[4].innerHTML = "HIDDEN";
}
else
{
row.cells[4].innerHTML = Number(data["Max Bid"]/100).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
}
}
} );
这里是来自cases_main_server_side_processing.php的结果格式:
$columns = array(
array( 'db' => 'id', 'dt' => "ID" ),
array( 'db' => 'status', 'dt' => "Status" ),
array( 'db' => 'ts_sale_date', 'dt' => "Sale Date" ,
'formatter' => function( $d, $row )
{
return date( 'm/d/y', strtotime($d));
}),
array( 'db' => 'max_bid', 'dt' => "Max Bid"),
array( 'db' => 'zestimate', 'dt' => "Zestimate" ,
'formatter' => function( $d, $row )
{
return number_format((float)($d/100), 2);
})
);
我的问题是:
我无法排序或搜索MaxBid列(因为我在javascript上处理结果" createdRow"函数,它实际上直接在数据库中进行排序/搜索)。我该怎么做?
处理单元格值可以搜索/排序的正确方法是什么,例如我必须输出一些单元格作为货币:$ 123,456.78但是将它们作为bigints保存到db:12345678?< / p>
脚本:DataTables