我在使用 Electron 创建的应用程序中有一个如下表。我正在使用 jQuery、Datatables 和 SQL.js:-
<table id="dataTable" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Date</th>
<th>Code</th>
<th>Category</th>
<th>Hours</th>
<th>Cost</th>
<th>Billed</th>
<th>Description</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Date</th>
<th>Code</th>
<th>Category</th>
<th>Hours</th>
<th>Cost</th>
<th>Billed</th>
<th>Description</th>
</tr>
</tfoot>
</table>
以下用于填充表格的代码无法正常工作:-
$(document).ready(function() {
var DB = null;
var t = $('#dataTable').DataTable();
$(".bottomMenuContainer").on("click", ".loadButton", function(e) {
var fs = require('fs');
var sql = require('sql.js');
var bfr = fs.readFileSync(__dirname + '/../data/EliteData.db');
DB = new sql.Database(bfr);
var stmt = DB.prepare("SELECT * FROM ProductEntries ORDER BY Category");
while(stmt.step()){
var row = stmt.getAsObject();
t.rows.add([row.Date, row.Code, row.Category, row.Hours, row.Cost, row.Billed, row.Description]).draw(false);
}
});
});
我得到了第 0 行第 1 列错误消息的请求未知参数“1”,当数据最终显示时,数据最终散布在表中,实际数据库中有 21 个结果而不是 3 个结果。
知道发生了什么吗?