I have been scratching my head for a while here, it seemed like a random bug at first but now I can reproduce it.
It happens when I have more than one column filter and when there is a datetime filter on for instance the second filtered column.
Say we have the following filter returned from dataSource.filter():
{
"filters"
: [
{
"logic"
:
"or"
,
"filters"
: [
{
"value"
: 3,
"operator"
:
"eq"
,
"field"
:
"powerState"
}
]
},
{
"logic"
:
"and"
,
"filters"
: [
{
"field"
:
"alarm1Created"
,
"operator"
:
"gt"
,
"value"
:
"2016-01-04T23:00:00.000Z"
},
{
"field"
:
"alarm1Created"
,
"operator"
:
"lt"
,
"value"
:
"2016-01-28T23:00:00.000Z"
}
]
}
],
"logic"
:
"and"
}
The odata filter generated from this is:
&$filter=(powerState eq 3 and (alarm1Created gt 2016-01-05T01:00:00+00:00 and alarm1Created gt 2016-01-29T00:00:00+00:00))
Which is as expected.
Now load the filter back using:
dataSource.query({
filter: filter,
sort: sort,
group: group,
pageSize: pageSize,
page: page
});
but now the odata url becomes
&$filter=(powerState eq 3 and (alarm1Created gt
'2016-01-05T00:00:00.000Z'
and alarm1Created lt
'2016-01-29T00:00:00.000Z'
))
which is of course incorrect. The alarm1Created datetimes are not parsed as datetimes but as strings!
This seems to happen only when the datetime is nested inside a parenthesis. Without the PowerState filters there is no problem with the datetimes.