我正在尝试将远程JSON文件加载到dynatables中,但是dynatables不会显示任何数据。
这是我的表
<table class="table table-striped" id="myTable">
<thead>
<th>orgid</th>
<th>uniqusers</th>
<th>transacs</th>
<th>traffic</th>
<th>advthreats</th>
<th>malware</th>
<th>org_name</th>
<th>domain</th>
<th>partner</th>
</thead>
<tbody>
</tbody>
</table>
这是我的剧本
$(document).ready(function() {
$('#myTable').dynatable({
dataset: {
ajax: true,
ajaxOnLoad: true,
ajaxUrl: 'betafile.json',
records: []
}
});
});
和JSON文件数据
{"records": [{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"412234 033129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."}, {"orgid":8140488,"uniqusers":"7","transacs":"13101121","traffic":"39907320 0170","advthreats":"13093","malware":"10","org_name":"Newham College of Further Education","domain":"newham.ac.uk","partner":"iCritical"}, {"orgid":11621785,"uniqusers":"8","transacs":"56850","traffic":"1011450886 ","advthreats":"5","malware":"0","org_name":"Limerick Education Centre","domain":"lec.ie","partner":"iCritical"},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inc."},
{"orgid":5529306,"uniqusers":"58","transacs":"11448173","traffic":"4122340 33129","advthreats":"28832","malware":"61","org_name":"Education Futures Group","domain":"vistacollege.edu","partner":"Teknas, Inctest."}],"queryRecordCount":"10","totalRecordCount":"12"}
请帮助
答案 0 :(得分:0)
尝试更改你的thead数据属性,就像这样(它对我有用):
<table class="table table-striped" id="myTable">
<thead>
<th data-dynatable-column="orgid">orgid</th>
<th data-dynatable-column="uniqusers">uniqusers</th>
<th data-dynatable-column="transacs">transacs</th>
<th data-dynatable-column="traffic">traffic</th>
<th data-dynatable-column="advthreats">advthreats</th>
<th data-dynatable-column="malware">malware</th>
<th data-dynatable-column="org_name">org_name</th>
<th data-dynatable-column="domain">domain</th>
<th data-dynatable-column="partner">partner</th>
</thead>
<tbody>
</tbody>
</table>