Skip to content

Commit

Permalink
Fields: Default filterValue for number field to undefined instead of 0
Browse files Browse the repository at this point in the history
Fixes: #125
  • Loading branch information
tabalinas committed Nov 1, 2016
1 parent a821f01 commit ebfc66b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demos/db.js
Expand Up @@ -5,7 +5,7 @@
loadData: function(filter) {
return $.grep(this.clients, function(client) {
return (!filter.Name || client.Name.indexOf(filter.Name) > -1)
&& (!filter.Age || client.Age === filter.Age)
&& (filter.Age === undefined || client.Age === filter.Age)
&& (!filter.Address || client.Address.indexOf(filter.Address) > -1)
&& (!filter.Country || client.Country === filter.Country)
&& (filter.Married === undefined || client.Married === filter.Married);
Expand Down
4 changes: 3 additions & 1 deletion src/fields/jsgrid.field.number.js
Expand Up @@ -13,7 +13,9 @@
readOnly: false,

filterValue: function() {
return parseInt(this.filterControl.val() || 0, 10);
return this.filterControl.val()
? parseInt(this.filterControl.val() || 0, 10)
: undefined;
},

insertValue: function() {
Expand Down
2 changes: 1 addition & 1 deletion tests/jsgrid.field.tests.js
Expand Up @@ -129,7 +129,7 @@ $(function() {
equal(field.filterTemplate()[0].tagName.toLowerCase(), "input");
equal(field.insertTemplate()[0].tagName.toLowerCase(), "input");
equal(field.editTemplate(6)[0].tagName.toLowerCase(), "input");
strictEqual(field.filterValue(), 0);
strictEqual(field.filterValue(), undefined);
strictEqual(field.insertValue(), 0);
strictEqual(field.editValue(), 6);
});
Expand Down

6 comments on commit ebfc66b

@NiceGuyNimni
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an estimation when this fix will be a part of a new release?
Meanwhile, how can I implement it in my local file?

@tabalinas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's plan the release on this week.

@NiceGuyNimni
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for bothering you man, just wanted to ask if you have any estimated date for the release.
This will solve a huge issue I have in production.
Thanks for the great work!

@tabalinas
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guynimni382, it's released several hours ago.

@NiceGuyNimni
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!!
Thanks man!

@nsisler7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im having issues with the CRUD layer. As I attempt to update the pre populated grid, no changes are made. Are these changes supposed to be made to the db.js file?

Please sign in to comment.