-
Notifications
You must be signed in to change notification settings - Fork 298
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
dgrid dstore collection - “or” filter not working as expected ? #1265
Comments
I can't reproduce this issue. Here is an example that shows require(['dstore/Memory'], function (Memory) {
var formatter = new Intl.DateTimeFormat();
var data = [];
for (var i = 1; i <= 10; i++) {
data.push({
id: i,
date1: new Date(Date.now() + (Math.random() - 0.5) * 864000000),
date2: new Date(Date.now() + (Math.random() - 0.5) * 864000000)
});
}
var store = new Memory({
data: data
});
function logIDs(results) {
console.log(results.map(function(item) {
return item.id;
}));
}
function logDates(results) {
console.log(results.map(function(item) {
return formatter.format(item.date1) + '~' + formatter.format(item.date2);
}));
}
logDates(data);
logIDs(store.filter(new store.Filter().or(
new store.Filter().gt('id', 7),
new store.Filter().lt('id', 4)
)).fetchSync());
logDates(store.filter(new store.Filter().or(
new store.Filter().lte('date1', new Date()),
new store.Filter().lte('date2', new Date())
)).fetchSync());
}); Either way, if this were an issue, it should probably be logged with dstore, not dgrid. If you can provide more information on your problem, please create an issue there. Thanks! |
Sorry, I just came back and realized I wasn't quite testing the same case you were describing. Indeed, the following seems to not work, even with simple numbers: store.filter(new store.Filter().or(
new store.Filter().gt('id', 7).lt('id', 10),
new store.Filter().lt('id', 4).gt('id', 1)
)); So |
I've logged SitePen/dstore#179 for this. In the interim, if you're using a Memory store, you can provide a custom filter function to store.filter(function (item) {
return (item.datefield1 >= start_date && item.datefield1 <= today) ||
(item.datefield2 >= start_date && item.datefield2 <= today);
}); |
Thank you! It worked! |
I'm working with Dojo dgrid and I have problem with dstore filtering with using "or" statement.
Both conditions works perfect when they are separatelly, but when I put them together into "or" filter it works like "and" statement: both have to be "true" to return values.
How to make "or" statement to work properly in dojo dgrid dstore?
The text was updated successfully, but these errors were encountered: