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

The fields "text" and "number" set default value in the filter when no value has been entered by the user #125

Closed
StefH opened this issue Oct 28, 2015 · 5 comments
Labels

Comments

@StefH
Copy link

StefH commented Oct 28, 2015

For the jsgrid.field.text, when the user does not search for this column, the filter still contains the default value ("" = empty string).

My proposal is to modify the filterValue function into:

filterValue: function() {
  return this.filterControl.val() !== "" ? this.filterControl.val() : undefined;
}

When do value is entered, this will return undefined.

Same as in the CheckboxField code:

filterValue: function() {
    return this.filterControl.get(0).indeterminate ? undefined : this.filterControl.is(":checked");
},

Same for the jsgrid.field.number, the default value contains a integer 0 when the user does not search on this.

But if this change breaks the implementation, it's maybe better to add a property named filterValueHasValue like this:

filterValueHasValue: function() {
    return this.filterControl.val() !== "";
},
@tabalinas
Copy link
Owner

In checkbox we have this implementation, because we need third state, true/false is not enough. Empty filter field value can be easily handled just like undefined. Moreover, this is real input value, no magic involved. Why you think undefined is better than empty string?

@StefH
Copy link
Author

StefH commented Oct 29, 2015

In case of empty string, you can indeed discuss that this is fine, however for an integer, the default value would be 0, which does not differ from a real 0 value, if you want to search for for all products which are sold out (number-in-stock=0) for example.

So for integer values, returning 'undefined' would be the best option. And if you build it for checkbox and integers, maybe it's best to build the same logic for all types.

@tabalinas
Copy link
Owner

For number field, it sounds really reasonable.

@osamahq
Copy link

osamahq commented Oct 17, 2016

@tabalinas I cant implement search for number field because I cant recognize if the user entered 0 or the number field is empty !!! thank you for your efforts

@tonisostrat
Copy link

As this bug is currently open you can/have to implement the proposed change in OP in your own code as a temporary work-around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants