好的,這是一個讓我瘋狂的問題。已添加數據(大小未定義)與已知列數(9)不匹配
我試圖創建一個jQuery DataTable,並不斷收到錯誤:
數據表警告(表ID =「屬性」):新增數據(大小未定義)不匹配已知數列(9)的
我有一個設置了9列(即9個<th>
塊在html)的表
的JavaScript似乎沒事看(儘管這將有助於如果有人會驗證肯定):
$tableProperties = $('#properties').dataTable({
sDom: '<"dataTables_header"<"dataTables_toolbar">rl>t<"dataTables_footer"ip>',
oLanguage: { sLengthMenu: "Show _MENU_ lines", sInfo: "Showing _START_ to _END_ of _TOTAL_ lines" },
iDisplayLength: <%: ShusterConnect.ConfigurationSettings.MgtPropertiesPerPage %>,
aLengthMenu: [[10, 20, 50, -1], [10, 20, 50, "All"]],
bPaginate: true,
sPaginationType: "listbox",
bLengthChange: true,
bFilter: false,
bInfo: true,
bAutoWidth: true,
bProcessing: true,
bServerSide: true,
sAjaxSource: "/property/QueryAllProperties",
aaSorting: [[ 5, "asc" ]], // default sorting column is Management Company
fnServerData: function (sSource, aoData, fnCallback) {
$.post(sSource, aoData, fnCallback);
},
fnRowCallback: function (tr, record, iDisplayIndex, iDisplayIndexFull) {
$('td:eq(7)', tr).html(renderActionTemplate(record[7], $('td:eq(4)', tr).text()));
$('td:eq(7)', tr).css("white-space", "nowrap");
if ($('td:eq(4)', tr).text() != "Yes")
$(tr).css("background-color", "#c0c0c0");
return tr;
},
aoColumns: [
{ "mDataProp": "ShusterPropertyID" },
{ "mDataProp": "ShusterCustomerID" },
{ "mDataProp": "BEPropertyID" },
{ "mDataProp": "BEUserName" },
{ "mDataProp": "IsManagementCompany" },
{ "mDataProp": "ManagementCompany" },
{ "mDataProp": "MappingFileType" },
{ "mDataProp": "Action", "bSortable": false}, // action
{ "mDataProp": "ParentId" } //Parent Id
],
});
});
我的JSON是返回一個aaData 9個值設置爲每個記錄: {"sEcho":"1","iTotalRecords":147,"iTotalDisplayRecords":147,"aaData":[{"ShusterCustomerId":"1057","ShusterPropertyId":"DEV","BEPropertyId":"4368058011","BEUserName":"Devon Oaks","IsManagementCompany":"","ManagementCompany":"Eliza Jennings Senior Care Network","MappingFileType":"Default","Action":"57","ParentId":""},{"ShusterCustomerId":"1058","ShusterPropertyId":"ELIZA","BEPropertyId":"4368056561","BEUserName":"Eliza Jennings Home","IsManagementCompany":"","ManagementCompany":"Eliza Jennings Senior Care Network","MappingFileType":"Default","Action":"58","ParentId":""}, ... {"ShusterCustomerId":"1168","ShusterPropertyId":"WESC","BEPropertyId":"3008297838","BEUserName":"Wesley Court Methodist Retirement Community","IsManagementCompany":"","ManagementCompany":"Sears Methodist Retirement System","MappingFileType":"PathLinks","Action":"243","ParentId":"232"}]}
所以......到底是什麼回事?我錯過了一些重要的東西嗎任何建議將不勝感激。
P.S.我確實花了一個小時搜索interwebs(和StackOverflow),但無法找到任何指出問題的東西...
只是爲了清楚起見,我使用jQuery 1.7.6 – SnagQueensHubby
ShusterPropertyID不等於ShusterPropertyId - 你有兩個人一樣,以及您的JSON數據不匹配aaColumns。我相信aaDataProp和aaColumns必須與正確的案例相匹配。 ShusterCustomerID和BEPropertyID是其他的。 – wilsjd
請分享表格html,並回應上述評論 –