Hi all,
I have the following data structure :
[ {
"supplierCode": "supplier1",
"supplierDesc": "supplier1Desc",
"pos": [ {
"poNum": "11111",
"materialNum": "matNum11",
"materialDesc": "matDesc11"
},
{ "poNum": "11112",
"materialNum": "matNum22",
"materialDesc": "matDesc22"}
] },
{"supplierCode": "supplier2",
"supplierDesc": "supplier2Desc",
"pos": [ {
"poNum": "22222",
"materialNum": "matNum11",
"materialDesc": "matDesc11"},
{"poNum": "22223",
"materialNum": "matNum22",
"materialDesc": "matDesc22"}]
}
]
My task is to filter data in JSON model by properties in pos array.
I tried the following approach:
myList = this.getView().byId("myList");
var binding = myList.getBinding("items");
if (!query) {
binding.filter([]);
} else {
binding.filter([new sap.ui.model.Filter([
new sap.ui.model.Filter("supplierCode", sap.ui.model.FilterOperator.Contains, query),
new sap.ui.model.Filter("supplierDesc", sap.ui.model.FilterOperator.Contains, query),
new sap.ui.model.Filter("pos/materialDesc", sap.ui.model.FilterOperator.Contains, query)
], false)]);
}
with no luck.
Also, I found out it is possible to do with ODataModel, but I didn't find anything regarding JSONModel.
Can such filtering be done at all?
Thank you.
Here is an example on test function under the constructor of the Filter : Filter result will return a line of list containing the materialDesc description introduced in the filter :