Skip to content

Instantly share code, notes, and snippets.

View NamTThai's full-sized avatar

Nam Thai NamTThai

  • Santa Barbara, CA
View GitHub Profile
_defaultFilter: function(value, headerName) {
var match = RegExp(this.filters[headerName], 'i');
return match.test(value);
}
eFilterCustom: function(headerName, filterValue, item) {
switch(headerName) {
case "ID":
switch(filterValue) {
case "Selected":
return item.selected;
case "Not Selected":
return !item.selected;
default:
return this._defaultFilter(item.id, headerName);
eFilter: function(item) {
var valid = true;
// this.filters is an Object that holds existing filters in all columns.
// Key is column name, value is filter value
// For example: {Dessert: "Cake", Calorie: /^\d{3}$/g}; Calorie filter is a regex indicating that number needs to have 3 digits
// This filter means to show only rows that have Cake in its Dessert column and 3 digits Calorie value
for (var headerName in this.filters) {
valid = valid && this.eFilterCustom(headerName, this.filters[headerName], item);
}
return valid;