Hello everybody,
my search filter doesn't work. I get this error in the console when it tries to create the Filter:
GET http://localhost:63342/MessageSender/firstKey 404 (Not Found)
That's weird, because the location of my .json file is http://localhost:63342/MessageSender/payloads/payloads.json
I tried to change the path (first argument) when creating the filter from firstkey into this String:
"payloads/payloads.json#/data/firstKey"
but then I got no error in the console, and the search filter still didn't work. How do I set the Filter path correctly so the search element works?
My controller:
sap.ui.define([ 'jquery.sap.global', 'sap/ui/core/mvc/Controller', 'sap/ui/core/Fragment', 'sap/ui/model/Filter', 'sap/ui/model/json/JSONModel', ], function(jQuery, Controller, JSONModel, Filter, Fragment) { "use strict"; var SenderController = Controller.extend("messagesender.Sender", { onInit: function() { this._payloadsModelJSON = new sap.ui.model.json.JSONModel(); this._oPayloadSelectDialog = sap.ui.xmlfragment("./messagesender.PayloadSelectDialog", this); this._oPayloadsModelJSON.loadData("payloads/payloads.json", '', false); //false for synchronous operation this._oPayloadSelectDialog.setModel(this._oPayloadsModelJSON); } handlePayloadSelectDialogSearch: function(oEvent) { var sValue = oEvent.getParameter("value"); var oFilter = new Filter("firstKey", sap.ui.model.FilterOperator.Contains, sValue); var oBinding = oEvent.getSource().getBinding("items"); oBinding.filter([oFilter]); } }
My fragment:
<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core"> <SelectDialog noDataText="No Payloads Found" title="Select Saved Payload" search="handlePayloadSelectDialogSearch" confirm="handlePayloadSelectDialogClose" close="handlePayloadSelectDialogClose" items="{/data}" > <CustomListItem type="Active" > <HBox height="64px" width="480px" alignItems="Center" class="sapUiSmallMarginBegin" justifyContent="SpaceBetween"> <VBox id="VBoxID"> <Label text="{firstKey}" class="sapMSLITitle" /> <Label text="{secondKey}" visible="false" /> <Label text="{thirdKey}" class="sapMSLIDescription"/> </VBox> <Button icon="sap-icon://display" class="sapUiSmallMarginEnd" press="handlePreviewPayload"/> </HBox> </CustomListItem> </SelectDialog> </core:FragmentDefinition>
And payloads/payloads.json file:
{"data": [{"firstKey":"request.xml"},{"firstKey":"request_live_nemo.xml"},{"firstKey":"request_migration.xml"},{"firstKey":"request_myriad.xml"},{"firstKey":"request_nemo.xml"},{"firstKey":"request_nemo_no_myriad.xml"},{"firstKey":"request_nemo_no_service_number.xml"},{"firstKey":"request_no_myriad.xml"} ]}