on 08-06-2015 8:53 AM
Hi UI5 gurus,
Been trying to follow 's advice here: https://scn.sap.com/thread/3735171
But I'm not having much luck...
The Problem
I can't seem to get sap.ui.model.Filter working with ODataModel read function!
var la_filters = new Array(); // Don't normally do this but just for the example.
var ld_date = new Date("2015-08-20"); // Javascript Date object
var lo_pickedDateFilter = new sap.ui.model.Filter({
path: "FilterEndDate",
operator: sap.ui.model.FilterOperator.EQ,
value1: ld_date
});
la_filters.push(lv_pickedDateFilter);
model.read("/TimeAccountCollection", null, la_filters);
// also tried the following but no luck...
model.read("/TimeAccountCollection", null, null, true, la_filters);
So what happens is that its seems like the read function accepts the array of Filter(s) as a urlParamter which is what I suspect I'm doing wrong.
Google Chrome Dev Tools shows that the request looks like this:
http://<host>:<port>/sap/opu/odata/sap/MY_CUSTOM_SERVICE/TimeAccountCollection?[object%20Object]
Which is not giving me my desired results...
A Solution - urlParameters
var valid_date = "2015-08-20T00:00:00" // hardcoded for example
var arrParams = ["$filter=FilterEndDate eq datetime'" + valid_date + "'"];
// Fire off a new GET request to update the model based on the date.
model.read("/TimeAccountCollection", null, arrParams);
Google Chrome Dev Tools shows that the request looks like this:
This solution works for now...
If it helps I'm on UI5 version 1.26.1 but this shouldn't be an issue.
What am I doing wrong in my sap.ui.model.Filter example for the ODataModel read function?
If anyone has any ideas I'd love to hear from you. I'm sure I'm missing something small.
Thanks.
Regards,
Ben
Hi.
model.read("/TimeAccountCollection", {
filters: la_filters
}
});
Regards,
Christopher
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use paramtrized second parameter
ODataModel.prototype.read = function(sPath, mParameters) {
...
aFilters = mParameters.filters;
...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
filter is a array,
declare your array like this,
var la_filters = [];
else add filter var like below,
Refer this links,
http://stackoverflow.com/questions/23128948/sapui5-how-to-filter-data-with-2-or-more-values
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.