Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbedair committed Jun 5, 2014
1 parent 119af22 commit 713000f
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions src/assets/js/jquery.saveselection.gridview.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,51 @@
* Init events for Bulk Actions
* @param id string the ID of the grid view container
*/
$.fn.yiiGridView.initBulkActions = function (id)
{
var grid = $('#'+id);
$.fn.yiiGridView.initBulkActions = function (id) {

$(document).on("click change", "#"+id+" input[type=checkbox]", function() {

if ($("#"+id+' tbody input[type=checkbox]:checked').length) {

$(".bulk-actions-btn", grid).removeClass("disabled");
$("div.bulk-actions-blocker",grid).hide();
}
else
{
$(".bulk-actions-btn", grid).addClass("disabled");
$("div.bulk-actions-blocker",grid).show();
}
var grid = $('#'+id);
if ($("#"+id+' tbody input[type=checkbox]:checked').length) {

$(".bulk-actions-btn", grid).removeClass("disabled");
$("div.bulk-actions-blocker",grid).hide();
} else {
$(".bulk-actions-btn", grid).addClass("disabled");
$("div.bulk-actions-blocker",grid).show();
}
});
};

/**
* Updating checkboxes after grid ajax updating
* @param id string the ID of the grid view container
*/
$.fn.yiiGridView.afterUpdateGrid = function (id)
{
var grid = $('#'+id);
$.fn.yiiGridView.afterUpdateGrid = function (id) {

if ($("#"+id+' tbody input[type=checkbox]:checked').length) {

$(".bulk-actions-btn", grid).removeClass("disabled");
$("div.bulk-actions-blocker",grid).hide();
$.each(checkedItems, function(index, item){

var grid = $('#'+id);

$(".bulk-actions-btn", grid).removeClass("disabled");
$("div.bulk-actions-blocker",grid).hide();
$.each(checkedItems, function(index, item) {
var row = $("input[value="+item+"]", grid);
if (!row.is(':checked')) {
row.attr("checked", "checked");
}
});
if (!row.is(':checked')) {
row.attr("checked", "checked");
}
});
}
};

/**
* Returns array of checked items ids
* @returns {Array}
*/
$.fn.yiiGridView.getCheckedItems = function (id)
{
return $("#"+id+' tbody input[type=checkbox]:checked').map(function() { return $(this).val(); }).get();
$.fn.yiiGridView.getCheckedItems = function (id) {
return $("#"+id+' tbody input[type=checkbox]:checked').map(function() { return $(this).val(); }).get();
}


Expand Down

0 comments on commit 713000f

Please sign in to comment.