Solved:
The events “rowselect” and “rowunselect” does not really work as expected:
rowselect fires
1. When a row is selected
2. When all rows are selected by clicking the “select-all-checkbox”
3. When all rows are UNselected by clicking the “select-all-checkbox”.
rowunselect fires
1. When a row is unselected
Note: rowunselect does NOT fire when all rows are unselected using the “select-all-checkbox”.
Solution (using an un-documented feature):
In the case “rowselect” was fired when clicking the “select-all-chenbox” the event-argument event.args.rowindex of the handler holds an array of indexes to the selected rows. i.e. an array of all indexes OR an empty array. By checking the length of the array you will know!
Example:
$("#theGrid").bind('rowselect', function (event) {
if (Array.isArray(event.args.rowindex)) {
if (event.args.rowindex.length > 0) {
alert("All rows selected");
} else {
alert("All rows unselected");
}
} else {
alert("Selected row has index = " + event.args.rowindex);
}
});
$("#theGrid").bind('rowunselect', function (event) {
alert("Unselected row has index = " + event.args.rowindex);
});