2
我在一個網站(asp.net)工作,我使用包含數據表模板和初始化的這個表此代碼:數據表通過下拉菜單選擇項過濾
if ($('body').data('page') == 'products') {
var opt = {};
// Tools: export to Excel, CSV, PDF & Print
opt.sDom = "<'row m-t-10'<'col-md-6'f><'col-md-6'T>r>t<'row'<'col-md-6'><'col-md-6 align-right'p>>",
opt.oLanguage = { "sSearch": "" } ,
opt.iDisplayLength = 15,
opt.oTableTools = {
"sSwfPath": "assets/plugins/datatables/swf/copy_csv_xls_pdf.swf",
"aButtons": ["csv", "xls", "pdf", "print"]
};
opt.aoColumnDefs = [
{ 'bSortable': false, 'aTargets': [6, 7, 8, 9] }
];
var oTable = $('#products-table').dataTable(opt);
oTable.fnDraw();
/* Add a placeholder to searh input */
$('.dataTables_filter input').attr("placeholder", "Search a product...");
/* Delete a product */
$('#products-table a.delete').on('click', function (e) {
e.preventDefault();
if (confirm("Are you sure to delete this product ?") == false) {
return;
}
var nRow = $(this).parents('tr')[0];
oTable.fnDeleteRow(nRow);
// alert("Deleted! Do not forget to do some ajax to sync with backend :)");
});
}
我想補充一個特定列的過濾器類型選擇(下拉框)。 有幫助嗎?
我有嘗試不通過的方式工作,THX。你的代碼很好,但模板的結構很複雜。 – alim91 2014-09-12 14:57:24