LoginSignup
0
0

More than 3 years have passed since last update.

DataTablesのフィルターにwrapperクラスのdivを作成する

Last updated at Posted at 2020-11-06

追記

DataTable ver1.10.4という古いの使い回してました。
公式からBootstrp3とか選択してv1.10.22を使用したらちゃんとwrapperついてたので、本記事の対応は不要でした!!!

ポイント

DataTablesの「検索窓」や「○○件表示」のdivには親クラスが内のでwrapper_divを指定して横並びとかできないのでJSで作成してみた。(できるかもしれんけど)
※スマホで見ると上記2つが縦に並んで気持ち悪い

メモ:
「○○件表示」は dataTables_length
「検索窓」は dataTables_filter
のclass名が自動で付与される。

それぞれ指定してwrapperクラスを作成するが、少し待機してからでないと上記2点も作成されていないので反映できない。
300ms待機してから実行するようにしている。

ソース

    $(function (){
        setTimeout(function () {
            $('.dataTables_length, .dataTables_filter').wrapAll('<div class="datatable-wrapper-div">');
        },300);
    });
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0