我在服务器中有REST服务,返回JSON数据。我正在获得价值,并能够使用下面的代码段在JQuery客户端上打印。但我使用的数据表不是渲染信息。我还在数据表中使用了aoColumns将JSON数据映射到表列。可能出了什么问题?
$.getJSON(dataSource, function(data) {
var items = [];
$.each(data, function(key, val) {
items.push('<li id="' + key + '">' + key + '</li>');
});
$('<ul/>', {
'class': 'my-new-list',
html: items.join('')
}).appendTo('body');
});
下面是从REST服务返回的JSON列名和值
* aprop : 1
* bprop : 7935408
* cprop : 2010-09-21 00:00:00.0
* dprop : Y
* eprop : 2
* fprop : 2010-09-21 16:10:22.0
* gprop : 3
* hprop : 10407198
* iprop : 4
数据表
oTable = $("#myTable").dataTable({
bJQueryUI: true,
"bPaginate": true,
//Pagination": "full_numbers",
"sPaginationType": "two_button",
"bProcessing": true,
"sAjaxSource": 'RequestTrades.htm',
"sScrollX": "100%",
"sScrollXInner": "110%",
"bScrollCollapse": true,
"aoColumnDefs": [{
"bSearchable": false,
"bVisible": false,
"aTargets": [1]
}],
"aoColumns": [
{ "sName": "aprop" },
{ "sName": "bprop" },
{ "sName": "cprop" },
{ "sName": "dprop" },
{ "sName": "eprop" },
{ "sName": "fprop" },
{ "sName": "gprop" },
{ "sName": "hprop" },
{ "sName": "iprop" }
]
});
这是我的表
<TABLE id=myTable cellpadding="0" cellspacing="0" border="0" class="display" width="100%" onmouseover="this.style.cursor='pointer'">
<THEAD>
<TR>
<TH width="100" >Col1</TH>
<TH width="100" >Col2</TH>
<TH width="200" >Col3</TH>
<TH width="221" >Col4</TH>
<TH width="221" >Col5</TH>
<TH width="400" >Col6</TH>
<TH width="1200" >Co7</TH>
<TH width="221" >Col8</TH>
<TH width="221" >Col9</TH>
</TR>
</THEAD>
<TBODY>
</TBODY>
</TABLE>