【问题标题】:Bootstrap table strict search for only 1 column引导表严格搜索仅 1 列
【发布时间】:2016-07-05 01:30:39
【问题描述】:

我在我的网站上使用 bootstrap-table,并且数据有一个字段 gender 以及所有其他 20 个字段。

我为这个表启用了data-search,为gender 字段启用了data-filter-control="select",因为它只有两个选项。

现在我的表格有strictSearch=false,因此用户可以轻松搜索,但这会导致gender 字段出现问题,因为两个性别都有单词male,所以当我只搜索male 时,它显示为两个性别。

我只想为gender 列启用严格搜索。

解决方案是什么?

【问题讨论】:

  • 那是数据表吗?或者你能告诉我们你正在使用的链接吗?
  • @claudios 我正在使用bootstrap-table
  • 如果你更改strictSearch=true会发生什么?
  • @claudios data-strict-search="true" 选项用于全表。因此将严格搜索所有列。我只想严格搜索gender

标签: jquery twitter-bootstrap twitter-bootstrap-3 bootstrap-table


【解决方案1】:

您还可以更改默认搜索,因为您需要使用给定代码的自定义搜索功能。

text:搜索文本

示例用法:

function customSearch(text) {
        //Search logic here.
        //You must use `this.data` array in order to filter the data. NO use `this.options.data`.
    }

你可以找到它here

【讨论】:

  • 它适用于所有列,而不适用于特定列。
【解决方案2】:

我认为您使用了 filter-control 扩展,因此您可以使用以下列选项:data-filter-strict-search="true"

https://bootstrap-table.com/docs/extensions/filter-control/#filterstrictsearch

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-06
    • 2023-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 1970-01-01
    相关资源
    最近更新 更多