Using checkbox and sortable on same column sorts when click on checkAll checkbox
See original GitHub issueUsing checkbox and sortable on same column sorts when you click on the checkAll checkbox. I would expect for sorting not to be affected when you click the checkAll checkbox. If you click on the checkAll button instead of the checkbox, the problem does not occur.
With pagination the problem is much more obvious because the checked rows seem to disappear when you click the selectAll checkbox.
Reproduced with the Online Editor on Chrome Version 78.0.3904.87 on Windows 10 with the following setup:
<div id="toolbar">
<button id="button" class="btn btn-secondary">checkAll</button>
<button id="button2" class="btn btn-secondary">uncheckAll</button>
</div>
<table
id="table"
data-toggle="table"
data-toolbar="#toolbar"
data-height="460"
data-url="json/data1.json"
data-pagination="true"
data-page-size="5">
<thead>
<tr>
<th data-field="state" data-checkbox="true" data-sortable="true" ></th>
<th data-field="id">ID</th>
<th data-field="name">Item Name</th>
<th data-field="price">Item Price</th>
</tr>
</thead>
</table>
<script>
var $table = $('#table')
var $button = $('#button')
var $button2 = $('#button2')
$(function() {
$button.click(function () {
$table.bootstrapTable('checkAll')
})
$button2.click(function () {
$table.bootstrapTable('uncheckAll')
})
})
</script>
To prevent this, I did the following:
$('input[name="btSelectAll"]').off('click').on("click", (function(e) {
let checked = $(this).prop("checked");
$table.bootstrapTable(checked ? "checkAll" : "uncheckAll");
e.stopPropagation();
}));
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to prevent click on "Select all" checkbox to affect header ...
I am using jQuery DataTables plugin. I created ...
Read more >Best practice for sorting and being able to "check all" in a table ...
I have a table as part of a form for which users can click the header row to sort by that column (and...
Read more >row-reorder, column sorting, and checkboxes - DataTables
I'm trying to add a checkbox to each field with a 'select all' option in the column header, I have it working at...
Read more >checkbox check/uncheck all not working after insert tablesorter
i have a gridview with a column of checkboxes. the check_all function work well but when i insert tablesorter to sort my gridview, ......
Read more >How to place 'check-all' checkbox in kendo grid column template
Also, for some reason the checkbox in the header does not get checked when I click it, instead when I click it, it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t understand why you want to use the checkbox and sortable on the same column.
Fixed in #4697