05_*_*ong 5 odata sapui5 sap-fiori
我有使用fiori元素的Fiori应用程序,我想调整UI5为$batch
调用中的OData生成的odata查询。
我打开了用于列表报告的livemode以及用于选择/过滤器和list of values
使用ValueList注释的smartfilter。但是问题是,当我在选择字段中键入过滤器值时(例如说要卖给),该$batch
调用将触发以下OData查询。
../invoice_list.xsodata/vlsoldto?sap-client=100&$skip=0&$top=10&$filter=startswith(SOLDTO___T,%27TEST%27)
Run Code Online (Sandbox Code Playgroud)
我想调整odata调用以使用'substringof'而不是'startswith'..因此如下所示。
../invoice_list.xsodata/vlsoldto?sap-client=100&$skip=0&$top=10&$filter=substringof(%27TEST%27,CRM_SOLDTO___T)
Run Code Online (Sandbox Code Playgroud)
我不知道该进行定制的地方。我知道如何进行Fiori元素扩展,但是要查找一些信息(如果它是扩展名),然后是哪种类型的扩展名,哪种事件,或者其他任何方法(如果不是扩展名)。我几乎不知道从哪里开始。
任何帮助表示赞赏。
您可以在 SmartFilterBar 中添加自己的字段,然后创建自己的自定义过滤器:
https://sapui5.hana.ondemand.com/#/topic/3a515829ffd74239878ebc0d453d001d
编辑:如果您想使用现有字段,您只需在事件sap.ui.model.FilterOperator.Contains
上推送新的过滤器即可beforeRebindTable
。
第 1 步:在manifest.json文件中注册您的扩展
"extends": {
"extensions": {
...
"sap.ui.controllerExtensions": {
...
"sap.suite.ui.generic.template.ListReport.view.Details": {
...
"controllerName": "com.acme.app.controller.ListReportExtension",
...
}
}
...
Run Code Online (Sandbox Code Playgroud)
第二步:实现控制器方法:
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;
}
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
115 次 |
最近记录: |