I need to create AdvancedCriteria in order to do filter data over a date range. I would like to generate this manually rather than use filter builder or something along those lines, since I have created my own search feature, but I heard this must be done using JSNI.
public static native JavaScriptObject getDateRangeJSObject(String field, Date from, Date to) /*-{
var advancedCriteria = {
_constructor:"AdvancedCriteria",
operator:"and",
criteria:[
{ fieldName: field, operator:"greaterOrEqual", value: from },
{operator: "and", criteria:[
{ fieldName: field, operator:"lessOrEqual", value: to }
]
}
]
}
return advancedCriteria;
}-*/;
which takes the field name to search (from the list grid) and two date objects.
I then use
AdvancedCriteria ac = new AdvancedCriteria(SearchWidget.getDateRangeJSObject("week_of", from_date, to_date));
wr_grid.fetchData(ac);
To create a new AdvancedCriteria. Am I doing it wrong? When I do the search, the grid shows ‘No items to view’ and the hosted mode shell displays some 'Malformed JSNI reference ‘constructor’ expect subsequent failures" notices (although I already had some to start with - more are created).