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的背景顏色不同)。