Skip to content

Commit ac8da0b

Browse files
committed
Reparse formatted value before sending to server. Resolves #75.
1 parent c3af5fb commit ac8da0b

File tree

2 files changed

+48
-15
lines changed

2 files changed

+48
-15
lines changed

Build/CommonAssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.5.19")]
19-
[assembly: AssemblyFileVersion("1.5.19")]
18+
[assembly: AssemblyVersion("1.5.20")]
19+
[assembly: AssemblyFileVersion("1.5.20")]
2020
//[assembly: AssemblyInformationalVersion("1.4.5-editlyalpha2")]

Griddly/Scripts/griddly.js

+46-13
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,9 @@
558558
if (!dontHide)
559559
filter.find(".filter-trigger").popover("hide");
560560

561-
var val = trimToNull(content.find("input").first().val());
561+
var val = trimToNull(this.getCleanedValue(content.find("input").first().val(), dataType));
562+
563+
content.find("input").first().val(val)
562564

563565
if (val != null)
564566
{
@@ -577,8 +579,11 @@
577579
}
578580
else if (filter.hasClass("griddly-filter-range"))
579581
{
580-
var val = trimToNull(content.find("input").first().val());
581-
var valEnd = trimToNull(content.find("input").last().val());
582+
var val = trimToNull(this.getCleanedValue(content.find("input").first().val(), dataType));
583+
var valEnd = trimToNull(this.getCleanedValue(content.find("input").last().val(), dataType));
584+
585+
content.find("input").first().val(val)
586+
content.find("input").last().val(valEnd)
582587

583588
if (val != null && valEnd != null)
584589
display = this.getFormattedValue(val, dataType) + " - " + this.getFormattedValue(valEnd, dataType);
@@ -963,25 +968,53 @@
963968
this.refresh(true);
964969
},
965970

966-
getFormattedValue: function (val, dataType)
971+
getCleanedValue: function (val, dataType)
967972
{
968973
switch (dataType)
969974
{
970975
case "Integer":
971-
{
972-
val = String(val).replace(/[^0-9]/g, "")
976+
val = String(val).replace(/[^0-9-]/g, "")
973977

974-
val = parseInt(val);
978+
if (val.length > 1)
979+
val = val.substr(0, 1) + val.substr(1).replace(/-/g, "");
980+
else if (val == '-')
981+
return null;
975982

976-
if (!isFinite(val))
977-
val = null;
983+
return val;
984+
case "Decimal":
985+
case "Currency":
986+
//case "Percent":
987+
val = String(val).replace(/[^0-9,.-]/g, "").replace(/,/g, "");
978988

979-
return val;
980-
}
989+
if (val.length > 1)
990+
val = val.substr(0, 1) + val.substr(1).replace(/-/g, "");
991+
else if (val == '-')
992+
return null;
993+
994+
return val;
995+
case "Date":
996+
return String(val).replace(/[^0-9a-zA-Z-\/]/g, "");
997+
default:
998+
return val;
999+
}
1000+
},
1001+
1002+
getFormattedValue: function (val, dataType)
1003+
{
1004+
val = this.getCleanedValue(val, dataType);
1005+
1006+
switch (dataType)
1007+
{
1008+
case "Integer":
1009+
val = parseInt(val);
1010+
1011+
if (!isFinite(val))
1012+
val = null;
1013+
1014+
return val;
9811015
case "Decimal":
9821016
case "Currency":
9831017
//case "Percent":
984-
val = String(val).replace(/[^0-9,.-]/g, "").replace(/,/g, "").replace(/\$/g, "");
9851018

9861019
// TODO: filter down to one decimal point
9871020
// TODO: filter out non numerics
@@ -1019,7 +1052,7 @@
10191052

10201053
return val;
10211054
case "Date":
1022-
val = parseForValidDate(String(val).replace(/[^0-9a-zA-Z-\/]/g, ""));
1055+
val = parseForValidDate(val);
10231056

10241057
if (val == null || !isFinite(val))
10251058
return null;

0 commit comments

Comments
 (0)