Knockout-Contrib / KoGrid

A Knockout DataGrid

Home Page:https://knockout-contrib.github.io/KoGrid/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Function "sortMMDDStr" throws an error stating "dateRE" is undefined.

saurabhmahajan opened this issue · comments

Function "sortMMDDStr" throws an error stating "dateRE" is undefined. Below is the code snippet and you can see the code
mtch = b.match(dateRE);
uses "dateRE" as it is, instead what it should be doing is calling it using
mtch = b.match(window.kg.sortService.dateRE);
I will submit a pull request and fix for the same.

-------- Code------

sortMMDDStr: function (a, b) {
var dateA, dateB, mtch, m, d, y;
mtch = a.match(window.kg.sortService.dateRE);
y = mtch[3];
d = mtch[2];
m = mtch[1];
if (m.length == 1) {
m = '0' + m;
}
if (d.length == 1) {
d = '0' + d;
}
dateA = y + m + d;
mtch = b.match(dateRE);
y = mtch[3];
d = mtch[2];
m = mtch[1];
if (m.length == 1) {
m = '0' + m;
}
if (d.length == 1) {
d = '0' + d;
}
dateB = y + m + d;
if (dateA == dateB) {
return 0;
}
if (dateA < dateB) {
return -1;
}
return 1;
},

I already fixed this on our local version. Change the following line:
mtch = b.match(dateRE);

It should read:
mtch = b.match(window.kg.sortService.dateRE);

The fix is available in 2.1.5 branch. 869208f


Going to mark this issue as duplicate although it was reported before #295