我目前在我的应用程序中使用 JQuery UI SelectMenu Widget。selectMenu 中的选项是在运行时根据 sql 表中的一些值填充的。
根据在 selectedMenu 中选择的选项,需要在特定列上过滤数据表。
.js 片段
$(document).ready(function() {
var table = $('.tableContent').DataTable({
"columnDefs" : [ {
"className" : "dt-center",
"targets" : "_all"
} ]
});
$("#osFamilySelect1").selectmenu({
change : function(event, ui) {
dropdownSelect = ui.item.value;
table.column(9).search(dropdownSelect, false, true, true).draw();
}
});
});
上述方法在选择某些内容时有效,但在首次加载页面时不起作用,即在首次加载页面时未过滤表格。
如何达到同样的效果。