我正在通過簡單的ajax調用接收數據的頁面上使用FooTable。我的頁面上的表是:在Footable中使用鏈接不工作?
<table id="orderDashboard" class="table table-bordered table-hover footable margin-top-20" data-type="html" data-paging="true" data-filtering="true" data-sorting="true" data-editing="false" data-page-size="50">
</table>
的JavaScript代碼來運行它是:
$(window).load(function() {
var myLink = "<a href='#' onclick='editRepairOrder();'>";
//$editorTitle = $('#editor-title'),
ft = FooTable.init('#orderDashboard', {
columns: [
{"name":"orderDate","title":"Order Date"},
{"name":"customer","title":"Customer"},
{"name":"numberOfParts","title":"Number of Parts"},
{"name":"OrderNum","title":"R2 Order #"},
{"name":"orderStatus","title":"Order Status"},
{"name":"lastUpdate","title":"Last Change Date"},
{"name":"id","title":"Action","breakpoints":"xs sm","type":"HTML","style":{"width":40,"maxWidth":40}}
],
rows: [
{"orderDate":"","customer":"","numberOfParts":"","orderNum":"","orderStatus":"","lastUpdate":"","id":""}
]
});
$.ajax({
type: "GET", url: "./getRepairsDashboard", dataType: "json",
success:function(data){
$.each(data, function(index, item){
var row = create_table_row(item);
$('table tbody').append(row).trigger('footable_redraw');
});
$('table').footable();
$('.footable').trigger('footable_redraw'); //force a redraw
},
error: function (req, status, err) {
console.log('add items to table error: ', status, err);
}
});
$('<a href="#"><span class="play"></span><span class="trackName">Track Name</span></a>')
function create_table_row (item) {
var row = $('<tr><td>' + item.orderDate + '</td><td>' + item.customer + '</td>' +
'<td>' + item.numberOfParts + '</td><td>' + item.orderNum + '</td><td>' + item.orderStatus + '' +
'</td><td>' + item.lastUpdate + '</td><td><a href=' + item.id +'>' + item.id + '</a></td></tr>');
return row;
}
$('table').footable();
});
然而,FooTable剔除的HTML 標籤,每當有數據填充。設置通過JavaScript列和行也留下如插入的數據之上的空白行:screenshot
如果我設置在表中我通過HTML列
<table id="orderDashboard" class="table table-bordered table-hover footable margin-top-20" data-type="html" data-paging="true" data-filtering="true" data-sorting="true" data-editing="false" data-page-size="50">
<thead>
<tr>
<th data-toggle="true">
Order Date
</th>
<th data-sort-ignore="true">
Customer
</th>
</tr>
</thead>
</table>
然後我得到了「沒有結果」在插入數據上方的默認消息行。所以看來我贏不了!我正在使用Bootstrap 3.這是一個Spring MVC應用程序。
我想知道如果DataTable框架會更適合。關於FooTable的文檔似乎圍繞着並且缺乏深度。
任何幫助真正感激!