Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom filter is not called for null values #7266

Open
ebq-m opened this issue Apr 4, 2024 · 6 comments
Open

Custom filter is not called for null values #7266

ebq-m opened this issue Apr 4, 2024 · 6 comments
Labels
Bug Issues which are marked as Bug filter-control Issues for the filter-control extension.

Comments

@ebq-m
Copy link

ebq-m commented Apr 4, 2024

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: #4494?
Not sure

Additional Context

No response

@ebq-m ebq-m added the Bug Issues which are marked as Bug label Apr 4, 2024
@wenzhixin wenzhixin added the filter-control Issues for the filter-control extension. label Apr 24, 2024
@wenzhixin
Copy link
Owner

@ebq-m
Copy link
Author

ebq-m commented Apr 24, 2024

Looks like the same code to me?

@ebq-m
Copy link
Author

ebq-m commented Apr 24, 2024

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

@wenzhixin
Copy link
Owner

wenzhixin commented Apr 24, 2024

Yes, I saved your code to the online editor.

@ebq-m
Copy link
Author

ebq-m commented Apr 24, 2024

Thank you! It wasn't formatted properly as well

@nubbeldupp
Copy link

I'd like to chime in on this. :)
I ran into the same issue having NULL Values in my Table.

I'm using

while ($row = oci_fetch_array($stmt, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : "&nbsp;") . "</td>\n";
    }
    echo "</tr>";
}

to break down the Array and replace NULL with &nbsp;
With BT 1.15.5 this prompted an "empty" Option in the Select-Filter.

Screenshot 2025-01-08 at 21 04 05

It doesn't look nice, but it worked. :)

With 1.24.0 this doesn't work anymore but it would be nice if it did.
For now as a workaround I replaced the &nbsp; with a hyphen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Issues which are marked as Bug filter-control Issues for the filter-control extension.
Projects
None yet
Development

No branches or pull requests

3 participants