OData demo
来源:互联网 发布:352净化器怎么样 知乎 编辑:程序博客网 时间:2024/06/04 19:03
1 , OData source
(1) Eclipse CDS
@AbapCatalog.sqlViewName: 'ZCDS_DEMO01_VIEW'@AbapCatalog.compiler.compareFilter: true@AccessControl.authorizationCheck: #CHECK@EndUserText.label: 'CDS DEMO - ZTEST001'@OData.publish: true --OData services ==> /IWFND/MAINT_SERVICE 添加服务,激活--@Search.searchable: truedefine view Zcds_Demo01 as select from ztest001 { key mandt as Mandt, key fld1 as Fld1, fld2 as Fld2, fld3 as Fld3}
(2) T-CODE : SEGW
实现 服务 (Service Implementation>>Right click>>Go to ABAP Workbench>>Method>>Inherited Methods)
2 , demo
view
<mvc:ViewcontrollerName="ZFIORI.controller.GridOData"xmlns="sap.ui.table"xmlns:mvc="sap.ui.core.mvc"xmlns:u="sap.ui.unified"xmlns:c="sap.ui.core"xmlns:m="sap.m"><m:Page class="sapUiContentPadding" showHeader="false" enableScrolling="false"><m:content><Table id="Products"selectionMode="MultiToggle"enableCellFilter="{ui>/cellFilterOn}"ariaLabelledBy="title"sort="sortTable"rows="{/ZCDS_DEMO01Set}"visibleRowCount="20"><toolbar><m:Toolbar><m:Title id="title" text="Products"></m:Title><m:ToolbarSpacer/><m:Buttonicon="sap-icon://decline" tooltip="Clear all filters"press="clearAllFilters"/><m:SearchFieldplaceholder="Filter"value="{ui>/globalFilter}"search="filterGlobally"width="15rem"/></m:Toolbar></toolbar><columns><Column width="5rem" filterProperty="Fld1" filterType="sap.ui.model.type.String" sortProperty="Fld1"><m:Label text="Product Key" /><template><m:Text text="{Fld1}"/></template></Column><Column width="10rem" filterProperty="Fld2" filterType="sap.ui.model.type.String" sortProperty="Fld2"><m:Label text="Product desc" /><template><m:Text text="{Fld2}"/></template></Column><Column width="10rem" ><m:Label text="Product Qty" /><template><m:Text text="{Fld3}"/></template></Column></columns> </Table></m:content></m:Page></mvc:View>
controller
sap.ui.define(["sap/ui/core/mvc/Controller","sap/ui/model/odata/v2/ODataModel","sap/ui/model/Filter","sap/ui/model/FilterOperator","sap/ui/model/Sorter"], function(Controller,ODataModel,Filter,FilterOperator,Sorter) {"use strict"; //var sServiceUrl = "https://<host>:<port>/sap/opu/odata/sap/<ServiceName>/";//"/proxy/https/<host>:<port>/sap/opu/odata/sap/<ServiceName>/";return Controller.extend("ZFIORI.controller.GridOData", {onInit : function () { // - 同源是可以正常使用 --跨域无法访问 (url前加proxy没有解决此问题)//var oModel = new ODataModel(sServiceUrl, true);//var oTable = this.getView().byId("Products"); //oTable.setModel(oModel);//oTable.bindRows("/ZCDS_DEMO01Set"); //数据集//需要有 MANIFEST.JSON 文件 与 COMPONENT.JS 文件 var oModel = this.getOwnerComponent().getModel(); oModel.setUseBatch(false); var oTable = this.getView().byId("Products"); oTable.setModel(oModel,"ui"); oTable.bindRows("/ZCDS_DEMO01Set"); this._oGlobalFilter = null;},_filter : function () {var oFilter = null;oFilter = this._oGlobalFilter;this.getView().byId("Products").getBinding("rows").filter(oFilter, "Application");},filterGlobally : function(oEvent) {var sQuery = oEvent.getParameter("query");this._oGlobalFilter = null; if (sQuery) {this._oGlobalFilter = new Filter([new Filter("Fld1", FilterOperator.Contains, sQuery),new Filter("Fld2", FilterOperator.Contains, sQuery)], false);}this._filter();},sortTable : function(oEvent) {var oCurrentColumn = oEvent.getParameter("column");var sOrder = oEvent.getParameter("sortOrder");var oSorter = new Sorter(oCurrentColumn.getSortProperty(), sOrder === "Descending");this.getView().byId("Products").getBinding("rows").sort(oSorter);},clearAllFilters : function() { //oEventvar oTable = this.getView().byId("Products");var oUiModel = this.getView().getModel("ui");oUiModel.setProperty("/globalFilter", ""); this._oGlobalFilter = null;this._filter();oTable.getBinding("rows").sort(null); var aColumns = oTable.getColumns();for (var i=0; i<aColumns.length; i++) {oTable.filter(aColumns[i], null);aColumns[i].setSorted(false);}}});});
model
--
component
sap.ui.define(['sap/ui/core/UIComponent'],function(UIComponent) {"use strict";var Component = UIComponent.extend("ZFIORI.GridOData.Component", {metadata : {//rootView : "ZFIORI.view.GridOData"manifest : "json"}});return Component;});
index.html
<script>sap.ui.getCore().attachInit(function() {new sap.m.App ({pages: [new sap.m.Page({title: "Icon Tab Bar - Filter", enableScrolling : true,content: [ new sap.ui.core.ComponentContainer({name : "ZFIORI.GridOData"})]})]}).placeAt("content");});</script>
阅读全文
0 0
- OData demo
- OData demo 2
- OData
- SAP UI5 Demo 绑定Odata数据
- OData语法
- OData语法
- Introducing OData
- 什么是OData?
- odata接口参考网站
- EXTJS Odata 可能解决方案
- 关于后端使用 OData
- nodejs模块 node-odata
- sapui5 访问OData数据
- Odata数据导入Excel
- OData Version 4.0 URL
- ODATA 系列文章
- Odata数据展示
- odata初探01
- rtsp协议详解
- 如何判断子页面iframe的高度
- jquery.cityselect.js城市插件
- 万能的林萧说:我来告诉你,一个草根程序员如何进入BAT。
- Servlet下的ServletContext
- OData demo
- 关于文本标签的使用
- 面试题_Selenium
- ThinkPHP3.2自带的七牛云配置使用
- js查看浏览器类型和版本
- 解决 github push failed (remote: Permission to userA/repo.git denied to userB.)
- 1115. Counting Nodes in a BST (30)
- Discuz X3.2 论坛关闭后,MySQL帖子导出为.csv
- 机器学习之数学基础(概率与统计推断、矩阵、凸优化)