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

Filter-control // null values in select filters not selectable #7679

Open
nubbeldupp opened this issue Jan 8, 2025 · 3 comments
Open

Filter-control // null values in select filters not selectable #7679

nubbeldupp opened this issue Jan 8, 2025 · 3 comments
Labels
help-wanted Issues we need or would love help from the community to resolve.

Comments

@nubbeldupp
Copy link

nubbeldupp commented Jan 8, 2025

Description

Hi,

I just redesigned a php project of mine and went from BootstrapTable 1.15.5 to 1.24.0.

Here's the HTML I'm using for the table:

<!-- Bootstrap Table CSS -->
<link href="https://unpkg.com/[email protected]/dist/bootstrap-table.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/extensions/filter-control/bootstrap-table-filter-control.css" rel="stylesheet">
 
<!-- Bootstrap Table Export CSS -->
<link href="https://unpkg.com/[email protected]/dist/extensions/export/bootstrap-table-export.css" rel="stylesheet">
 
<table 
	style="white-space:nowrap;"
	id="hanaTable" 
	class="table table-striped"
	data-toggle="table"
	data-pagination="true"
	data-search="true"
	data-show-columns="true"
	data-show-export="true" 
	data-export-options="true"        
	data-page-size="15"
	data-page-list="[15, 25, 50, All]"
	data-filter-control="true">
<thead>
<tr>
<th data-field="VERSION" data-filter-control="select" data-sortable='true'>VERSION</th>
</tr>
</thead>
<!-- Bootstrap Table Core and Extensions -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/bootstrap-table.min.js"></script>]
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/extensions/filter-control/bootstrap-table-filter-control.min.js"></script>]

I also have an issue when I want to filter for empty attributes.
With 1.15.5 I had die option to select "Empty". With 1.24.0 I can't get it working to show empty values.

1.24.0
Screenshot 2025-01-08 at 21 04 25
1.15.5
Screenshot 2025-01-08 at 21 04 05

Any help would be highly appreciated.

And thanks for providing such an awesome tool!

Example(s)

No response

@nubbeldupp nubbeldupp added the help-wanted Issues we need or would love help from the community to resolve. label Jan 8, 2025
@nubbeldupp
Copy link
Author

nubbeldupp commented Jan 8, 2025

Ignore the first part with unsorted select options... sometimes you got to describe your problem to actually find the solution.
I just went through the documentation again and found "data-sort-select-options" 🙈

While this works like a charm, using the data-filter-order-by="desc" in the Column-Definition does sort it DESC but also puts me all the way at the bottom. Haven't found a solution for that... YET :D
Screenshot 2025-01-08 at 21 35 12

@nubbeldupp nubbeldupp changed the title Filter-control // Data in select filters not sorted & null values not selectable Filter-control // null values in select filters not selectable Jan 8, 2025
@Pavel12313
Copy link

Hey, for the empty values filtering in 1.24.0 you'll need to add data-filter-default="" to your th element:

<th data-field="VERSION" 
    data-filter-control="select" 
    data-sortable='true'
    data-filter-default="">VERSION</th>

For the sorting issue you mentioned in your edit, try adding data-filter-strict-search="false" along with your data-filter-order-by="desc". This should keep the sort order without jumping to the bottom.

Good luck

@nubbeldupp
Copy link
Author

Thank you for your suggestions.
I was playing around with the code a bit and compared it to the "old" PHP I had and found one key difference.

There was a difference in the breakdown of the array which lead to empty <td></td> in the HTML.
I used
echo "<td>" . htmlspecialchars($item ?? '') . "</td>";

I now updated it to use

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>";
}

which gives me a <td>&nbsp;</td> instead.
With the old Version of BT this was recognised by Filter-Control and prompted a "empty" Select-Value.
This doesn't seem to be the case anymore and I also found an open Bug-Report for it while looking for possible solutions: https://github.com/wenzhixin/bootstrap-table/issues/7266

For now I'll make it work using a dash (-) instead of "&nbsp;" to replace NULL-Values so I can filter for it.


Regarding the data-filter-order-by ="desc" using strict-search didn't work for me.
Still looking for a way to get it working. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help-wanted Issues we need or would love help from the community to resolve.
Projects
None yet
Development

No branches or pull requests

2 participants