首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Fiori元素-自定义$batch查询

Fiori元素-自定义$batch查询
EN

Stack Overflow用户
提问于 2019-08-19 09:15:53
回答 1查看 1.4K关注 0票数 5

我有使用Fiori元素的fiori应用程序,我想调整UI5在$batch调用中为odata生成的OData查询。

我已经将livemode转到列表报告,smartfilter用于选择/筛选,并使用list of values注释。但是问题是,当我在选择字段中输入筛选值时(比如出售给),$batch调用触发OData的下面的查询。

代码语言:javascript
复制
../invoice_list.xsodata/vlsoldto?sap-client=100&$skip=0&$top=10&$filter=startswith(SOLDTO___T,%27TEST%27)

我想调整odata调用,使其使用'substringof‘而不是’startswith‘。如下所示。

代码语言:javascript
复制
../invoice_list.xsodata/vlsoldto?sap-client=100&$skip=0&$top=10&$filter=substringof(%27TEST%27,CRM_SOLDTO___T)

我不知道在哪里我可以进行这种定制。我知道如何做Fiori元素扩展,但是如果它是一个扩展,那么是什么类型的扩展,什么事件,或者任何其他方法,如果不是扩展的话,我会寻找一些信息。我不知道从哪里开始。

任何帮助都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2019-10-29 18:04:49

您可以在SmartFilterBar中添加您自己的字段,然后创建您自己的自定义过滤器:

https://sapui5.hana.ondemand.com/#/topic/3a515829ffd74239878ebc0d453d001d

编辑:,如果您想使用现有的字段,只需在beforeRebindTable事件上按一个带有sap.ui.model.FilterOperator.Contains的新筛选器即可。

步骤1:在manifest.json文件中注册您的扩展名

代码语言:javascript
复制
"extends": {
   "extensions": {
      ... 
      "sap.ui.controllerExtensions": { 
         ...
         "sap.suite.ui.generic.template.ListReport.view.Details": { 
            ... 
            "controllerName": "com.acme.app.controller.ListReportExtension",
            ...
         }
      } 
      ...

步骤2:实现控制器方法:

代码语言:javascript
复制
sap.ui.controller("com.acme.app.controller.ListReportExtension", {
        onBeforeRebindTableExtension: function(oEvent) {
        var oBindingParams = oEvent.getParameter("bindingParams");
        oBindingParams.parameters = oBindingParams.parameters || {};

        var oSmartTable = oEvent.getSource();
        var oSmartFilterBar = this.byId(oSmartTable.getSmartFilterId());
        var vCategory;
        if (oSmartFilterBar instanceof sap.ui.comp.smartfilterbar.SmartFilterBar) {
            //Custom price filter
            var oCustomControl = oSmartFilterBar.getControlByKey("CustomPriceFilter");
            if (oCustomControl instanceof sap.m.ComboBox) {
                vCategory = oCustomControl.getSelectedKey();
                switch (vCategory) {
                    case "0":
                        oBindingParams.filters.push(new sap.ui.model.Filter("Price", "LE", "100"));
                        break;
                    case "1":
                        oBindingParams.filters.push(new sap.ui.model.Filter("Price", "GT", "100"));
                        break;
                    default:
                        break;
                }
            }
        }
    }
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57553700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档