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

Add "allow_blank" option (default is "true", but it should be "false" IMHO) #112

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ All available parameters (detailed explanation inside jquery.dataTables.yadcf.js
* date_format
* ignore_char
* filter_match_mode
* allow_blank
* select_type
* select_type_options
* case_insensitive
Expand Down
18 changes: 14 additions & 4 deletions jquery.dataTables.yadcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@
Default value: contains
Possible values: contains / exact / startsWith
Description: Allows to control the matching mode of the filter (supported in select / auto_complete / text filters)


* allow_blank
Required: false
Type: boolean
Default value: true
Description: Allows to have a "" (blank value or empty string) as option for the select filter_type (supported in text / html)


* select_type
Required: false
Type: String
Expand Down Expand Up @@ -251,6 +258,7 @@ var yadcf = (function ($) {
date_format : "mm/dd/yyyy",
ignore_char : undefined,
filter_match_mode : "contains",
allow_blank: true,
select_type : undefined,
select_type_options : {},
case_insensitive : true
Expand Down Expand Up @@ -1240,6 +1248,7 @@ var yadcf = (function ($) {
date_format,
ignore_char,
filter_match_mode,
allow_blank,

options,
options_tmp,
Expand Down Expand Up @@ -1296,6 +1305,7 @@ var yadcf = (function ($) {
ignore_char = new RegExp(columnObj.ignore_char, "g");
}
filter_match_mode = columnObj.filter_match_mode;
allow_blank = columnObj.allow_blank;

if (column_number === undefined) {
alert("You must specify column number");
Expand Down Expand Up @@ -1364,7 +1374,7 @@ var yadcf = (function ($) {
} else {
col_inner_data = col_inner_elements.selector;
}
if (!(col_filter_array.hasOwnProperty(col_inner_data))) {
if (!(col_filter_array.hasOwnProperty(col_inner_data)) && (allow_blank || col_inner_data.trim() !== "")) {
col_filter_array[col_inner_data] = col_inner_data;
options.push(col_inner_data);
}
Expand All @@ -1378,7 +1388,7 @@ var yadcf = (function ($) {
}
for (k = 0; k < col_inner_elements.length; k++) {
col_inner_data = col_inner_elements[k];
if (!(col_filter_array.hasOwnProperty(col_inner_data))) {
if (!(col_filter_array.hasOwnProperty(col_inner_data)) && (allow_blank || col_inner_data.trim() !== "")) {
col_filter_array[col_inner_data] = col_inner_data;
options.push(col_inner_data);
}
Expand All @@ -1399,7 +1409,7 @@ var yadcf = (function ($) {
} else {
col_inner_data = dot2obj(data[j]._aData, column_number_data);
}
if (!(col_filter_array.hasOwnProperty(col_inner_data))) {
if (!(col_filter_array.hasOwnProperty(col_inner_data)) && (allow_blank || col_inner_data.trim() !== "")) {
col_filter_array[col_inner_data] = col_inner_data;
options.push(col_inner_data);
}
Expand Down