$(function() {
var aoColumns=[{"sTitle":"REGION."},{"sTitle"
:"TOTAL TSI."},{"sTitle":"branchId"},{"sTitle":1},{"sTitle":"1 % AGE"},{"sTitle":2},{"sTitle":"2 % AGE"
},{"sTitle":3},{"sTitle":"3 % AGE"},{"sTitle":4},{"sTitle":"4 % AGE"},{"sTitle":5},{"sTitle":"5 % AGE"
},{"sTitle":6},{"sTitle":"6 % AGE"},{"sTitle":7},{"sTitle":"7 % AGE"},{"sTitle":8},{"sTitle":"8 % AGE"
},{"sTitle":9},{"sTitle":"9 % AGE"},{"sTitle":10},{"sTitle":"10 % AGE"},{"sTitle":11},{"sTitle":"11 % AGE"},{"sTitle":12},{"sTitle":"12 % AGE"},{"sTitle":13},{"sTitle":"13 % AGE"},{"sTitle":14},{"sTitle"
:"14 % AGE"},{"sTitle":15},{"sTitle":"15 % AGE"},{"sTitle":16},{"sTitle":"16 % AGE"},{"sTitle":17},{"sTitle"
:"17 % AGE"},{"sTitle":18},{"sTitle":"18 % AGE"},{"sTitle":19},{"sTitle":"19 % AGE"},{"sTitle":20},{"sTitle"
:"20 % AGE"},{"sTitle":21},{"sTitle":"21 % AGE"},{"sTitle":22},{"sTitle":"22 % AGE"},{"sTitle":23},{"sTitle"
:"23 % AGE"},{"sTitle":24},{"sTitle":"24 % AGE"},{"sTitle":25},{"sTitle":"25 % AGE"},{"sTitle":26},{"sTitle"
:"26 % AGE"},{"sTitle":27},{"sTitle":"27 % AGE"}];
var aaData=[["Visakhapatnam","7","6676",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
$('#performanceTable').dataTable({
"bJQueryUI" : true,
"sPaginationType" : "full_numbers",
"sScrollY" : 320,
"bDestroy": true,
"scrollX": true,
"aaData" : aaData,
"aoColumns" : aoColumns,
});
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.7/js/jquery.dataTables.min.js"></script>
<table id="performanceTable" style="cellspacing:0;width:100%;" class="display"></table>
&#13;
得到类似的错误:
TypeError:c.sTitle.replace不是函数
需要帮助..........
答案 0 :(得分:4)
我不熟悉datatables.js,但.replace函数依赖于变量是一个字符串,但我可以在数据中看到有分配给Title的整数。响起警钟......虽然数据表可能会应对它。如果你将标题号括在&#34;&#34;。
,它是否仍会发生答案 1 :(得分:1)
所有sTitle值必须是字符串,而不是“sTitle”:1使用“sTitle”:“1”依此类推
j$(function() {
var aoColumns=[{"sTitle":"REGION."},{"sTitle"
:"TOTAL TSI."},{"sTitle":"branchId"},{"sTitle":"1"},{"sTitle":"1 % AGE"},{"sTitle":"2"},{"sTitle":"2 % AGE"
},{"sTitle":"3"},{"sTitle":"3 % AGE"},{"sTitle":"4"},{"sTitle":"4 % AGE"},{"sTitle":"5"},{"sTitle":"5 % AGE"
},{"sTitle":"6"},{"sTitle":"6 % AGE"},{"sTitle":"7"},{"sTitle":"7 % AGE"},{"sTitle":"8"},{"sTitle":"8 % AGE"
},{"sTitle":"9"},{"sTitle":"9 % AGE"},{"sTitle":"10"},{"sTitle":"10 % AGE"},{"sTitle":"11"},{"sTitle":"11 % AGE"},{"sTitle":"12"},{"sTitle":"12 % AGE"},{"sTitle":"13"},{"sTitle":"13 % AGE"},{"sTitle":"14"},{"sTitle"
:"14 % AGE"},{"sTitle":"15"},{"sTitle":"15 % AGE"},{"sTitle":"16"},{"sTitle":"16 % AGE"},{"sTitle":"17"},{"sTitle"
:"17 % AGE"},{"sTitle":"18"},{"sTitle":"18 % AGE"},{"sTitle":"19"},{"sTitle":"19 % AGE"},{"sTitle":"20"},{"sTitle"
:"20 % AGE"},{"sTitle":"21"},{"sTitle":"21 % AGE"},{"sTitle":"22"},{"sTitle":"22 % AGE"},{"sTitle":"23"},{"sTitle"
:"23 % AGE"},{"sTitle":"24"},{"sTitle":"24 % AGE"},{"sTitle":"25"},{"sTitle":"25 % AGE"},{"sTitle":"26"},{"sTitle"
:"26 % AGE"},{"sTitle":"27"},{"sTitle":"27 % AGE"}];
var aaData=[["Visakhapatnam","7","6676",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]];
j$('#performanceTable').dataTable({
"bJQueryUI" : true,
"sPaginationType" : "full_numbers",
"sScrollY" : 320,
"bDestroy": true,
"scrollX": true,
"aaData" : aaData,
"aoColumns" : aoColumns,
});
});
希望它有所帮助, 丹