Add a select all checkbox at table header dynamically

* implements wishlist at bug 959017

Change-Id: I22a1fc3007dcf69e5f3f0d9eac48adbe62ad8035
This commit is contained in:
Andy Chong 2012-03-19 11:07:17 +08:00
parent f2c4e80fce
commit b3c70356b4
3 changed files with 12 additions and 2 deletions

View File

@ -145,7 +145,7 @@ var Horizon = function() {
$("form :checkbox").on("click", function (evt) {
var $form = $(this).closest("form");
var any_checked = $form.find(":checkbox").is(":checked");
var any_checked = $form.find("tbody :checkbox").is(":checked");
// Enable the button if any checkbox is checked,
// Disable if all checkbox is cleared

View File

@ -26,5 +26,15 @@ horizon.addInitFunction(function() {
}
});
// Add a select all checkbox at table header
$('table thead .multi_select_column').append('<input type="checkbox">');
$('table thead .multi_select_column :checkbox').click(function(evt) {
var $this = $(this),
$table = $this.closest('table'),
is_checked = $this.prop('checked'),
checkboxes = $table.find('tbody :checkbox');
checkboxes.prop('checked', is_checked);
});
horizon.datatables.update();
});

View File

@ -738,7 +738,7 @@ th.multi_select_column, td.multi_select_column {
width: 25px;
}
td.multi_select_column {
th.multi_select_column, td.multi_select_column {
text-align: center;
}