SAPUI5教程——Aggregation Binding的应用
2017-09-15 11:52
239 查看
前言
对于SAPUI5的程序开发而言,通常我们会使用XML View, 但是在某种特殊情况下,需要动态绑定数据,或者声场动态view, 这个时候难免会使用JS 去处理,因此 Aggregation Binding的用法,我们一定要有所了解。数据模型绑定
我们以一个combox为例: 如果用js view,可以使用如下代码。var oItemTemplate = new sap.ui.core.ListItem({text:"{name}"}); var oComboBox = new sap.ui.commons.ComboBox({ items: { path: "/company/contacts", template: oItemTemplate } });
如果使用Aggregation binding 的方式,可以按照如下方式:
oComboBox.bindAggregation("items", "/company/contacts", new sap.ui.core.ListItem({text:"{name}"}));
解除绑定:
oComboBox.unbindAggregation("items");
Filter 和sorter的使用
var oSorter = new sap.ui.model.Sorter("name", true); // sort descending var oFilter1 = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.StartsWith, "M"); var oFilter2 = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.Contains, "Paz"); var oFilter3 = new sap.ui.model.Filter("name", sap.ui.model.FilterOperator.BT, "A","G"); // name between A and G // manual sorting oTable.getBinding("rows").sort(oSorter); // manual filtering oTable.getBinding("rows").filter([oFilter1,oFilter2,oFilter3]); oComboBox.getBinding("items").filter([oFilter1,oFilter2,oFilter3]);
相关文章推荐
- SAPUI5教程——SAP Fiori应用类型分析(Transactional, Fact Sheets, Analytical)
- SAPUI5教程——MessageStrip的应用场景
- SAPUI5教程——框架简介以及应用实践
- Vaadin Web应用开发教程(30):UI布局-GridLayout布局
- HTML5开发移动web应用——SAP UI5篇(1)
- SAPUI5教程——ABAP环境下SAP Fiori 系统搭建以及开发实践
- SAPUI5拓展标准应用的View原理分析及应用实践
- HTML5开发移动web应用——SAP UI5篇(6)
- Vaadin Web应用开发教程(34):UI布局-TabSheet布局
- SAPUI5教程——ActionSheet的应用
- SAPUI5教程——Content Densities
- HTML5开发移动web应用——SAP UI5篇(2)
- HTML5开发移动web应用——SAP UI5篇(7)
- HTML5开发移动web应用——SAP UI5篇(9)
- SAPUI5教程——The project is corrupted because its '.user.project.json' file has an invalid JSON
- SAPUI5教程——URLHelper的使用技巧
- Vaadin Web应用开发教程(29):UI布局-VerticalLayout和HorizontalLayout布局
- HTML5开发移动web应用——SAP UI5篇(8)
- QtQuick桌面应用开发指导 1)关于教程 2)原型和设计 3)实现UI和功能_A
- SAPUI5教程——MaskInput的妙用