Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved issue where in checkbox filter selection was not working whe… #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions ext.headerfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
sortDescImage: "../images/sort-desc.png"
};
var $menu;

var workingFilters = [];

function init(g) {
options = $.extend(true, {}, defaults, options);
grid = g;
Expand Down Expand Up @@ -134,11 +135,11 @@
columnDef.filterValues = columnDef.filterValues || [];

// WorkingFilters is a copy of the filters to enable apply/cancel behaviour
var workingFilters = columnDef.filterValues.slice(0);
var workingFiltersLocalCopy = columnDef.filterValues.slice(0);

var filterItems;

if (workingFilters.length === 0) {
if (workingFiltersLocalCopy.length === 0) {
// Filter based all available values
filterItems = getFilterValues(grid.getData(), columnDef);
}
Expand All @@ -160,7 +161,7 @@
var filterOptions = "<label><input type='checkbox' value='-1' />(Select All)</label>";

for (var i = 0; i < filterItems.length; i++) {
var filtered = _.contains(workingFilters, filterItems[i]);
var filtered = _.contains(workingFiltersLocalCopy, filterItems[i]);

filterOptions += "<label><input type='checkbox' value='" + i + "'"
+ (filtered ? " checked='checked'" : "")
Expand All @@ -174,7 +175,7 @@
$('<button>OK</button>')
.appendTo($menu)
.bind('click', function (ev) {
columnDef.filterValues = workingFilters.splice(0);
columnDef.filterValues = workingFilters.slice(0);
setButtonImage($menuButton, columnDef.filterValues.length > 0);
handleApply(ev, columnDef);
});
Expand All @@ -183,6 +184,7 @@
.appendTo($menu)
.bind('click', function (ev) {
columnDef.filterValues.length = 0;
workingFilters = [];
setButtonImage($menuButton, false);
handleApply(ev, columnDef);
});
Expand Down