【问题标题】:Bootstrap-Table Plugin, Filter by initial search valueBootstrap-Table 插件,按初始搜索值过滤
【发布时间】:2015-07-09 03:36:03
【问题描述】:

使用 bootstrap-table 插件 (http://bootstrap-table.wenzhixin.net.cn/documentation/) 我正在尝试设置一个在加载表时自动搜索默认搜索值的表。我在 javascript 文件中设置了默认值,但它不会启动搜索,除非您单击搜索框并按任意键。

我还尝试使用此页面上推荐的一些代码 (with the Bootstrap Table plugin, how to set a search string on first load?) 创建一个新的 javascript 文件以在其他所有操作之后加载,它设置了初始值,但有同样的问题。我试图弄清楚如何在不按键的情况下初始化搜索。

var srch_str = 'v1.00';
var bstable_first_load = true;

$(document.getElementById('server_table')).on('load-success.bs.table',function () {//when the table is loaded the first time and visible, set the search string...
    if(srch_str.length > 0 && bstable_first_load){$('.fixed-table-toolbar').find('.search > :input').val(srch_str);
    bstable_first_load = false};
})

【问题讨论】:

  • 您的控制台有错误吗?另外我认为它不会影响任何东西,但是您使用的是 Javascript 的 document.getElementById() 和 jQuery 的 .on() 函数。这对我来说看起来很奇怪:P
  • 不,它不会给出任何错误。

标签: javascript jquery twitter-bootstrap bootstrap-table


【解决方案1】:

看来他们最近在最新版本中添加了此功能:

data-search-text="Your Search Query"

【讨论】:

    猜你喜欢
    • 2015-03-06
    • 1970-01-01
    • 2013-01-20
    • 1970-01-01
    • 2019-09-12
    • 2015-05-27
    • 2023-04-07
    • 2012-02-12
    • 2012-12-04
    相关资源
    最近更新 更多