wenzhixin / bootstrap-table

An extended table to integration with some of the most widely used CSS frameworks. (Supports Bootstrap, Semantic UI, Bulma, Material Design, Foundation, Vue.js)
https://bootstrap-table.com/
MIT License
11.71k stars 4.44k forks source link

Custom filter is not called for null values #7266

Open ebq-m opened 3 months ago

ebq-m commented 3 months ago

Bootstraptable version(s) affected

latest (online editor)

Description

I'm using a custom filter control function I think a user (currently me) might need a filter to search for empty/null values as well

Example(s)

<table
  id="table"
  data-filter-control="true"
  data-show-search-clear-button="true">
  <thead>
    <tr>
      <th data-field="id">ID</th>
      <th data-field="price" data-filter-control="select" data-filter-custom-search="final_cat_custom_filter">Item Price</th>
    </tr>
  </thead>
</table>

<script>
  $(function() {
    var data = [
    {
    "id": 1,
    "price": 1
    },
    {
    "id": 1,
    "price": null
    }
    ]
    $('#table').bootstrapTable({'data': data})
  })

  function final_cat_custom_filter(...x) {
    alert(JSON.stringify(x))
  }

</script>

Possible Solutions

I think this commit introduced this bug: https://github.com/wenzhixin/bootstrap-table/pull/4494? Not sure

Additional Context

No response

wenzhixin commented 3 months ago

Online example: https://live.bootstrap-table.com/code/wenzhixin/17502

ebq-m commented 3 months ago

Looks like the same code to me?

ebq-m commented 3 months ago

When you change the select filter, it only alerts one time when it should've done 2 times because there are two rows

wenzhixin commented 3 months ago

Yes, I saved your code to the online editor.

ebq-m commented 3 months ago

Thank you! It wasn't formatted properly as well