close
想要用別的自己的搜尋區塊替換掉dataTable預設的search box
如圖
有兩個步驟:
1. 把search box的功能套到自己的搜尋區塊中
$('#searchBar').keyup(function(){
oTable.search($(this).val()).draw() ;
})
oTable為目的的dataTable
2. 移除dataTable原生的search box
在dataTable宣告中加入
initComplete : function() {
// 移除預設的search區塊
$("#target-datatable_filter").detach();
},
這樣就OK了!
--
參考自
https://stackoverflow.com/questions/29120672/jquery-datatable-search-box-reposition
https://stackoverflow.com/questions/5990386/datatables-search-box-outside-datatable
全站熱搜