How to cancel a sort event after it is fired?
How to cancel a sort event after it is fired?
tpc
Posts: 12Questions: 0Answers: 0
Is it possible to cancel a sort event after it is fired?
I have a checkbox column in my table with a "check-all" checkbox in the header. When the checkbox in the header is clicked I want to prevent the sorting from occurring however if any other portion of the header is click I want it to sort. Here's what I've come up with so far but I am not sure how to cancel the sort.
Click event of the "check-all" checkbox
[code]
var checkallClicked = false;
$('#check-all').click(function() {
checkallClicked = true;
...
});
[/code]
Click/sort event of the header
[code]
$('.check-all-header').click(function(){
if (checkallClicked) {
checkallClicked = false;
return false;
}
});
[/code]
I have a checkbox column in my table with a "check-all" checkbox in the header. When the checkbox in the header is clicked I want to prevent the sorting from occurring however if any other portion of the header is click I want it to sort. Here's what I've come up with so far but I am not sure how to cancel the sort.
Click event of the "check-all" checkbox
[code]
var checkallClicked = false;
$('#check-all').click(function() {
checkallClicked = true;
...
});
[/code]
Click/sort event of the header
[code]
$('.check-all-header').click(function(){
if (checkallClicked) {
checkallClicked = false;
return false;
}
});
[/code]
This discussion has been closed.
Replies
Allan
[code]
$('.check-all-header').click(function(e){
if (checkallClicked) {
checkallClicked = false;
e.stopPropagation();
return false;
}
});
[/code]
Allan
As a very hackish work around I put 1.5% width columns on either side of the checkbox column and turned off sorting on the 1% width checkbox column.
So now if a user clicks the headers on either side of the checkbox it will sort the checkbox row.