关于 SAP UI5 OData V4 模型的 Property Binding 使用介绍

Property binding 和一个对象的值关联。

下面的例子:使用控制器方法 formatPhoneNumbersAsCSV 显示业务合作伙伴联系人的电话号码列表,以逗号分隔:


    

上面 XML 视图里,在 Text 控件里,显示 id 为 42 的 Business Partner 模型的属性值 BP_2_CONTACT,并且用自定义格式器 .formatPhoneNumbersAsCSV 在电话号码之间加上逗号分隔符。

OData V4 模型根据控件或应用程序请求的数据范围, 自动确定系统查询选项 $top 和 $skip.

在下面的示例中,生成的第一个请求是 GET People(‘angelhuffman’)/Friends?$expand=Friends&$skip=0&$top=107。 $top 的值是根据请求数据的长度 (7) 加上控件提供的预取大小 (100) 计算得出的。


    
    ...
    

另一种分页机制是服务器驱动分页,服务器只返回请求数据的一部分以限制响应大小。 自 SAPUI5 1.72 起,OData V4 模型支持此机制。该模型会将检索到的数据与对控件或应用程序的响应一起提供。 后续请求不会再自动触发,只有在控件或应用程序向模型请求 附加数据时才会触发。

只有 list 和 context binding 支持 OData 系统查询选项 $apply、$count、$expand、$filter、$orderby、$search 和 $select,property binding 不支持。

使用 JavaScript 进行数据绑定的例子:

oView.byId("SalesOrderTable").bindItems({
    path : "/SalesOrderList",
    parameters : {
        "$count" : true,
        "$expand" : {
            "SO_2_SOITEM" : {
                "$orderby" : "ItemPosition",
                "$select" : ["ItemPosition", "Quantity", "QuantityUnit", "SalesOrderID"]
            }
        },
        "$filter" : "BuyerName ge 'M'",
        "$orderby" : "GrossAmount desc",
        "$select" : ["BuyerName", "CurrencyCode", "GrossAmount", "Note", "SalesOrderID"]
    }
});

使用 XML 视图进行数据绑定的例子:

$expand 不仅仅可以是字符串,也可以是一个 JSON 对象:

OData V4 模型允许绑定由参数 $count 设置为 true 的 ODataListBinding 读取的实体集合的内联计数。不活跃的上下文(也就是说,没有显示在当前列表控件里的记录) 不影响这个计数;

在下面的示例中,表标题绑定到 $count,因此表示绑定到表的集合中的销售订单实体的数量。

</content> </Toolbar> </headerToolbar> ... </Table> </code></pre> </div> </div> <!-- m3 END --> <div class="page"> <ul class="clearfix m01"> <li> <a href="/24475491/viewspace-2889528/">关于 SAP UI5 OData V4 模型的 refresh 方法</a> </li> <li> <a href="/24475491/viewspace-2889531/">关于 SAP UI5 OData V4 模型的类型自动识别</a> </li> </ul> </div> </div> <footer> <a href="http://www.itpub.net">ITPUB论坛</a> | <a href="http://blog.chinaunix.net/">chinaunix博客</a> | <a href="http://bbs.chinaunix.net/">chinaunix论坛</a><br> 北京皓辰网域网络信息技术有限公司. 版权所有 </footer> <script> $(function(){ $("#fenlei").click(function(){ $("#left_1").show(); $("#left_2").show(); }); }) </script> </body> </html> <script language="javascript" src="http://stat.it168.com/pv.js"></script> <script> function sendPV(){ var pvTrack = new PvTrack(); pvTrack.type = 35; // 频道类别ID pvTrack.channel = 532; // 频道ID pvTrack.pageType = 0; pvTrack.track(); } window.setTimeout("sendPV()", 1000); </script> <div class="share_box"> <div class="share"> <div class="share_tit">分享到</div> <div class="share_close"></div> <ul class="share_list"> <a href="http://service.weibo.com/share/share.php?url=http://m.blog.itpub.net/24475491/viewspace-2889529/&appkey=&title=关于 SAP UI5 OData V4 模型的 Property Binding 使用介绍&language=zh_cn"><li><span class="weibo">新浪微博</span></li></a> <a href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=http://m.blog.itpub.net/24475491/viewspace-2889529/&title=关于 SAP UI5 OData V4 模型的 Property Binding 使用介绍&desc=Property binding 和一个对象的值关联。 下面的例子:使用控制器方法 formatPhoneNumbersAsCSV 显示业务合作伙伴联系人的电话号码列表,以逗号分隔: <SimpleForm binding="{/BusinessPartnerList('42')}"> <Label text="Phon&summary=&site=&pics="><li><span class="qq"> QQ空间</span></li></a> </ul> <div class="weixin2"> <em></em> <i>请使用浏览器的分享功能分享到微信等</i></div> </div> </div> <script> $(".fenxiang").click(function(){ $(".share_box").show(); }); $(".share_close").click(function(){ $(".share_box").hide(); }); $(".backTop").click(function(){ $('html,body').animate({ scrollTop: 0 }, 300) }) $('.content p br').parents('p').each(function (k,v) { if ($(v).html() == '') { $(v).css('display','none') } }) </script> <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> <script> var videoContainer = {}; $(document).delegate('.fake-video-btn', 'click', function () { var width = $(this).parent('.video-container').width(); var height = $(this).parent('.video-container').height(); var $this = $(this); var videoid = $(this).data('videoid'); var aliplayerid = $this.closest('.video-container').attr('id'); $.ajax({ url: 'http://blog.itpub.net/getvidoeinfo?videoid=' + videoid , type: 'get' , success: function (ret) { if (ret.code == 200) { videoContainer[videoid] = new Aliplayer({ id:aliplayerid, autoplay:true, width:width + 'px', height:height + 'px', format: "", vid:videoid, playauth:ret.data.PlayAuth, cover:ret.data.VideoMeta.CoverURL, skinLayout:[ //按钮UI {name:"bigPlayButton","align":"cc","x":15,"y":12},//播放 {name: "H5Loading", align: "cc"}, {name: "errorDisplay", align: "tlabs", x: 0, y: 0}, {name: "infoDisplay"}, {name:"tooltip", align:"blabs",x: 0, y: 56}, {name: "thumbnail"}, { name: "controlBar", align: "blabs", x: 0, y: 0, children: [ {name: "progress", align: "blabs", x: 0, y: 44}, {name: "playButton", align: "tl", x: 15, y: 12}, {name: "timeDisplay", align: "tl", x: 10, y: 7}, {name: "fullScreenButton", align: "tr", x: 10, y: 12}, {name:"subtitle", align:"tr",x:15, y:12}, {name:"setting", align:"tr",x:15, y:12}, {name: "volume", align: "tr", x: 5, y: 10} ] } ] },function(player){ $this.siblings('img').remove(); $this.remove(); player.on('play',function(e) { for (var key in videoContainer) { if (videoid != key) { videoContainer[key].pause(); } } }); }); } else { alert(ret.msg); } } }) }); $(function() { var mkeditor = editormd.markdownToHTML("doc-content", {//注意:这里是上面DIV的id htmlDecode : "style,script,iframe", emoji : false, taskList : true, tex : true, // 默认不解析 flowChart: true, // flowChart : true, // 默认不解析 // sequenceDiagram : true, // 默认不解析 codeFold : true }); }); wx.config({ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: 'wx4d058320abe98d01', // 必填,公众号的唯一标识 timestamp: 1794940612, // 必填,生成签名的时间戳 nonceStr: 'tqzXJFeUIGAR1cI7', // 必填,生成签名的随机串 signature: 'c28844ff2f231f7d8ff9a6090e5ed156cc8eb270',// 必填,签名,见附录1 jsApiList: [ 'onMenuShareTimeline', 'onMenuShareAppMessage' ] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function(){ // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。 var title = '关于 SAP UI5 OData V4 模型的 Property Binding 使用介绍'; var desc = ""; var link = 'http://m.blog.itpub.net/24475491/viewspace-2889529/'; var imgUrl = $(".main img:first").attr('src'); if(!imgUrl){ imgUrl = 'http://m.blog.itpub.net/static/images/share.png?v1'; } console.log(imgUrl); wx.onMenuShareAppMessage({ //分享给朋友 title: title, // 分享标题,可在控制器端传递 desc: desc,//分享的描述,可在控制器端传递 link: link, // 分享链接,可在控制器端传递 imgUrl: imgUrl, // 分享图标 ,可在控制器端传递 success: function() {}, cancel: function() {} }); wx.onMenuShareTimeline({ //分享到朋友圈 title: title, // 分享标题,可在控制器端传递 desc: desc,//分享的描述,可在控制器端传递 link: link, // 分享链接,可在控制器端传递 imgUrl: imgUrl, // 分享图标 ,可在控制器端传递 success: function() {}, cancel: function() {} }); }); </script> </body> </html>