LoginSignup
3
3

More than 5 years have passed since last update.

jquery datatables filterより便利。 フィールド列を指定して検索

Last updated at Posted at 2017-08-06

以下のような感じでOK。
コピペじゃ動かんかもしれんので、参考までにね。
カラム番号、検索したい文字列

フィルター使うより、こっちのがわかりやすい。


<script>
    $(function () {

        table = $("#foo-table").DataTable();

        // #testhoge をクリックすると table の 2列目から 728を検索して返す
        // 列は 0 列目から始まる。
        $(document).on('click', '#testhoge', function() {
            table.column(2).search("検索したい文字")
                .draw();
        });



    });
</script>

<span id="testhoge">テストで検索</span>

<table id="foo-table">
    <thead>
    <tr>
        <th>
            <input type="checkbox" class="check" value="">
        </th>
        <th>
            <i class="fa fa-gear"></i>
        </th>
        <th>ID</th>
        <th>サイト情報</th>
        <th>テンプレート</th>
        <th>タグ</th>


    </tr>
    </thead>
</table>



3
3
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
3
3