突出显示搜索文本 bootstrap table
Highlight search text bootstrap table
我正在尝试实施 jquery plugin for highlighting search text to my app and I'm using this topic,我已将 jquery 插件添加到我的应用程序并添加以下行:
$table.highlight($(".search.bs.table").val());
但是搜索文字还是没有高亮显示。有人可以解释一下,我的错误在哪里?
代码:
function initTable() {
$table.bootstrapTable({
filterControl: true,
//data: url,
//url: 'data/events.json',
height: getHeight(),
formatNoMatches: function () {
return "Please, choose your category";
}
});
// sometimes footer render error.
setTimeout(function () {
$table.bootstrapTable('resetView');
}, 200);
$table.on('check.bs.table uncheck.bs.table ' +
'check-all.bs.table uncheck-all.bs.table', function () {
$remove.prop('disabled', !$table.bootstrapTable('getSelections').length);
// save your data, here just save the current page
selections = getIdSelections();
// push or splice the selections if you want to save all data selections
});
$table.on('all.bs.table', function (e, name, args) {
console.log(name, args);
});
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
"use strict";
console.log(e);
console.log(text);
});
$remove.click(function () {
var ids = getIdSelections();
$table.bootstrapTable('remove', {
field: 'id',
values: ids
});
$remove.prop('disabled', true);
});
$(window).resize(function () {
$table.bootstrapTable('resetView', {
//height: getHeight()
});
});
}
我明白了,它是如何工作的
右侧代码下方(将此代码放在 inittable 中):
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
$table.highlight(text);
console.log(e);
console.log(text);
});
css:
.highlight {background-color: yellow}
版本 >= 1.18.x 你可以使用 data-search-highlight
<table data-search-highlight="true"></table>
我正在尝试实施 jquery plugin for highlighting search text to my app and I'm using this topic,我已将 jquery 插件添加到我的应用程序并添加以下行:
$table.highlight($(".search.bs.table").val());
但是搜索文字还是没有高亮显示。有人可以解释一下,我的错误在哪里?
代码:
function initTable() {
$table.bootstrapTable({
filterControl: true,
//data: url,
//url: 'data/events.json',
height: getHeight(),
formatNoMatches: function () {
return "Please, choose your category";
}
});
// sometimes footer render error.
setTimeout(function () {
$table.bootstrapTable('resetView');
}, 200);
$table.on('check.bs.table uncheck.bs.table ' +
'check-all.bs.table uncheck-all.bs.table', function () {
$remove.prop('disabled', !$table.bootstrapTable('getSelections').length);
// save your data, here just save the current page
selections = getIdSelections();
// push or splice the selections if you want to save all data selections
});
$table.on('all.bs.table', function (e, name, args) {
console.log(name, args);
});
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
"use strict";
console.log(e);
console.log(text);
});
$remove.click(function () {
var ids = getIdSelections();
$table.bootstrapTable('remove', {
field: 'id',
values: ids
});
$remove.prop('disabled', true);
});
$(window).resize(function () {
$table.bootstrapTable('resetView', {
//height: getHeight()
});
});
}
我明白了,它是如何工作的 右侧代码下方(将此代码放在 inittable 中):
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
$table.highlight(text);
console.log(e);
console.log(text);
});
css:
.highlight {background-color: yellow}
版本 >= 1.18.x 你可以使用 data-search-highlight
<table data-search-highlight="true"></table>