Jquery 查询数据表时需要帮助
我犯了个错误 “未捕获的语法错误:意外的标记{-dataTables.bootstrap.min.css:1” 作为一个初学者,我尽了最大努力,但它找不到解决方案。servlet的响应是Json数据 那是下面的格式Jquery 查询数据表时需要帮助,jquery,datatables,Jquery,Datatables,我犯了个错误 “未捕获的语法错误:意外的标记{-dataTables.bootstrap.min.css:1” 作为一个初学者,我尽了最大努力,但它找不到解决方案。servlet的响应是Json数据 那是下面的格式 { "TransferMoneyHistory":[ { "amount":1000, "transactionDate":{ "date":1, "hours":5,
{
"TransferMoneyHistory":[
{
"amount":1000,
"transactionDate":{
"date":1,
"hours":5,
"seconds":0,
"month":0,
"timezoneOffset":-330,
"year":70,
"minutes":30,
"time":2,
"day":4
}
}
]
}
我需要将列索引显示为“金额”和“交易”
谢谢
要使用jQueryDataTable,我建议您首先看一看。 在您的情况下,要正确显示数据,请执行以下操作: 1.Json响应应该如下所示
{
"recordsFiltered" : 1,
"data" : [ {
"amount":1000,
"transactionDate":{
"date":1,
"hours":5,
"seconds":0,
"month":0,
"timezoneOffset":-330,
"year":70,
"minutes":30,
"time":2,
"day":4
}
} ],
"draw" : 2,
"recordsTotal" : 1
}
2.通过参考,列应设置为
"columns": [
{
// title of the column
"title":"Amount",
// the property of data in json response to show
"data": "amount"
},
{
"title":"TransactionDate",
"render": function(data, type, row, meta){
// need further handle for nested property,
// refer to
https://datatables.net/reference/option/columns.render
}
}
]
您的html是否将dataTables.bootstrap.min.css加载到标记中而不是标记中?是的,我做了更改它现在正在工作,但还有一个问题它没有反映在html页面上。我认为问题在于列命名。您能帮我吗?谢谢,Clayton,
“成功”
dataTables中的处理程序AJAX是“非法的”,使用dataSrc
。您还需要一个“数据”:“TransactionDate”
。
"columns": [
{
// title of the column
"title":"Amount",
// the property of data in json response to show
"data": "amount"
},
{
"title":"TransactionDate",
"render": function(data, type, row, meta){
// need further handle for nested property,
// refer to
https://datatables.net/reference/option/columns.render
}
}
]