Datatables - Search Box outside datatable

前端 未结 11 1348
攒了一身酷
攒了一身酷 2020-11-30 17:08

I\'m using DataTables (datatables.net) and I would like my search box to be outside of the table (for example in my header div).

Is this possible ?

11条回答
  •  囚心锁ツ
    2020-11-30 17:42

    You can use the sDom option for this.

    Default with search input in its own div:

    sDom: '<"search-box"r>lftip'
    

    If you use jQuery UI (bjQueryUI set to true):

    sDom: '<"search-box"r><"H"lf>t<"F"ip>'
    

    The above will put the search/filtering input element into it's own div with a class named search-box that is outside of the actual table.

    Even though it uses its special shorthand syntax it can actually take any HTML you throw at it.

提交回复
热议问题