0
我在我的应用程序中使用引导数据表。我使用服务器端使用Ajax从MySQL数据库中获取值。php引导数据表服务器
$(document).ready(function() {
var dataTable = $('#employee-grid').DataTable({
"processing": true,
"serverSide": true,
"ajax":{
url :"employee-grid-data.php", // json datasource
type: "post", // method , by default get
error: function(){ // error handling
$(".employee-grid-error").html("");
$("#employee-grid").append('<tbody class="employee-grid-error"><tr><thcolspan="3">No data found in the server</th></tr></tbody>');
$("#employee-grid_processing").css("display","none");
}
}
});
在员工电网data.php
while($row=mysqli_fetch_array($query)) { // preparing an array
$nestedData=array();
$nestedData[] = $row["employee_name"];
$nestedData[] = $row["employee_salary"];
$nestedData[] = $row["employee_age"];
$data[] = $nestedData;
}
$json_data = array(
"draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval($totalData), // total number of records
"recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data // total data array
);
echo json_encode($json_data); // send data as json format
所以,我在找的是 - 我要添加单独的类,每个TR一行。在数据表中我看不到任何tr。那么我怎样才能为tr添加一个类。 (基于条件,tr的背景颜色不同)。