简体   繁体   English

引导表插件,按初始搜索值过滤

[英]Bootstrap-Table Plugin, Filter by initial search value

Using the bootstrap-table plugin ( http://bootstrap-table.wenzhixin.net.cn/documentation/ ) I'm trying to set up a table that automatically searches for the default search value when the table loads. 我正在使用bootstrap-table插件( http://bootstrap-table.wenzhixin.net.cn/documentation/ )来建立一个表,该表在加载表时自动搜索默认搜索值。 I set the default value inside the javascript file, but it won't initiate the search unless you click in the search box and press any key. 我在javascript文件中设置了默认值,但是除非您在搜索框中单击并按任意键,否则它不会启动搜索。

I also tried creating a new javascript file to load after everything else, using some of the code recommended on this page ( with the Bootstrap Table plugin, how to set a search string on first load? ) and it sets the initial value, but has the same problem. 我还尝试使用此页面上建议的一些代码( 使用Bootstrap Table插件,如何在首次加载时设置搜索字符串? )创建一个新的javascript文件,以便在所有其他操作之后加载 ,并设置了初始值,但是具有同样的问题。 I'm trying to figure out how i can initialize the search without pressing a key. 我试图弄清楚如何可以在不按任何键的情况下初始化搜索。

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};
})

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

data-search-text="Your Search Query"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM