在js中自定义搜索:
$(document).on("click", ".btn-singlesearchone", function () {
var options = table.bootstrapTable('getOptions');
options.pageNumber = 1;
options.queryParams = function (params) {
return {
search: params.search,
sort: params.sort,
order: params.order,
offset: params.offset,
limit: params.limit,
filter: JSON.stringify({'getcs.orderstatus':'value2'}),
op: JSON.stringify({'getcs.orderstatus': 'like'}),
};
};
table.bootstrapTable('refresh', {});
Toastr.info("查询成功");
return false;
});
自定义搜索后,发现通用搜索失效了,发现是没有发送查询参数
image.png
解决方法,对比了两个版本的bootstrap-table-commonsearch.js文件(前面是新版,后面是旧版):
新版:
BootstrapTable.prototype.onCommonSearch = function () {
var searchQuery = getSearchQuery(this);
this.trigger('common-search', this, searchQuery);
this.options.pageNumber = 1;
this.refresh({});
};
改为旧版,问题解决:
BootstrapTable.prototype.onCommonSearch = function () {
var searchQuery = getSearchQuery(this);
var params = getQueryParams(this.options.queryParams({}), searchQuery, true);
this.trigger('common-search',this, params,searchQuery);
this.options.pageNumber = 1;
this.options.queryParams = function (options) {
return $.extend({},options,params);
};
this.refresh({query: params});
};