Jquery数据表不会被解释为jsonarray值。我在表中只得到一个字符。
<table border="1" cellspacing="0" cellpadding="0" id="products" style="clear:both;">
<thead>
<tr>
<th>Product</th>
<th>Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
来自服务器的实际数据格式:
["Element software","Software dist","Global envir","Software","Software list"]
jquery数据表代码:
var oTable = $("#products").dataTable({
"aaData" : data,
"bProcessing" : true,
"sPaginationType" : "full_numbers",
"bJQueryUI" : true,
"bRetrieve" : true,
"bPaginate" : true,
"bStateSave" : true,
"bSort" : true,
"aaSorting" : [[ 4, "desc" ]],
"iDisplayLength" : 25,
"oLanguage": {
"sProcessing": "processing",
"sEmptyTable": "No records found."
}
});
动作类:
JSONArray ja = new JSONArray();
try {
Iterator it = List.iterator();
while(it.hasNext()){
SearchResult part = (SearchResult) it.next();
ja.add(part.getlist1());
ja.add(part.getlist2());
findList.addAll(ja);
}
返回findList,这是arraylist。
如何将数据解释为数据表?
答案 0 :(得分:2)
如果表中有2列,则需要一个包含2个元素数组的数组作为数据输入:
[["Element software", "descr1"], ["Software dist", "descr2"],
["Global envir", "descr3"], ["Software", "descr4"], ["Software list", "descr5"]]