Open axelmangr opened 9 years ago
This is cause by the browser setting the checkbox to checked and then the "select" function inverting the selection for all the checked (it shoud exclude the recently checked) I found a solution for this:
--- jquery.bootgrid.js
+++ jquery.bootgrid.js
@@ -1586,8 +1586,14 @@
if (!this.options.multiSelect)
{
- this.element.find("tbody > tr " + selectBoxSelector + ":checked")
- .trigger("click" + namespace);
+ var lastId = this.selectedRows[this.selectedRows.length-1];
+ var checkboxes = this.element.find("tbody > tr " + selectBoxSelector + ":checked");
+ for (i = 0; i < checkboxes.length; i++) {
+ var $checkbox = $(checkboxes[i]);
+ if (lastId != $checkbox.val()) {
+ $checkbox.trigger("click" + namespace);
+ }
+ }
}
for (i = 0; i < this.selectedRows.length; i++)
I was in a hurry, if should be a more elegant and simpler way to fix this
I am terribly sorry for such a late response.
Thank you very much for the fix
/axelmangr
Is this going to be included in a release?
Hello,
it appears that there is an issue when using multiSelect=false and trying to click the checkbox on the grid.
When clicking the row (in case rowSelect = true) the selection works fine, but in case the user tries to click the check box nothing happens.
Inside the Grid.prototype.select function the variable this.selectedRows initially contains the rows to select. But, after the for loop which triggers the click on the selected rows (for deselecting the previously selected ones since we are talking about single select, empties the this.selectedRows array. Finally, when the loop starts for selecting the clicked checkbox it finds the this.selectedRows array empty, so nothing happens.
Could you plz look into this and create an update version?
thanx /axelmangr