【问题标题】:How to disable realtime search from datatable searching?如何从数据表搜索中禁用实时搜索?
【发布时间】:2020-11-27 02:20:33
【问题描述】:
[This is my datatable.][1]
  • 此输入框是一个搜索框。当您在其中输入文本时,搜索处理在 实时,但我想在按下回车键或丢失时进行搜索 重点 。有什么解决办法吗?

【问题讨论】:

    标签: javascript jquery web datatable


    【解决方案1】:
        $('#user_table thead tr').clone(true).appendTo( '#user_table thead' );
    $('#user_table thead tr:eq(1) th').each( function (i) {
        var title = $(this).text();
        var id = $(this).attr('id');
        //var id = $(this).attr('name');
        $(this).html( '<input type="text" id="' + id + '_search"placeholder="'+title+'" />' );
        //$(this).html( '<input type="text" name="' + name + '_search"placeholder="Search '+title+'" />' );
        $( 'input', this ).on( 'keyup change clear', function (e) {
        if(e.which == 13) {
            if ( table.column(i).search() !== this.value ) {
                table
                .column(i)
                .search( this.value )
                .draw();
            }
        }
        });
    });
    

    这是这个问题的完美答案。 我发现了这一点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-15
      • 1970-01-01
      • 1970-01-01
      • 2011-04-08
      • 2018-02-10
      • 2019-01-08
      相关资源
      最近更新 更多