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

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()