如何基于json属性将项目绑定到控制器 [英] How to bind items to a controller based on json property

查看:62
本文介绍了如何基于json属性将项目绑定到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的json对象.我想用键:"month"为对象创建一个表

The following is my json object. I want to make a table for the object with the key:"month"

 Object
   oData
   details:
   Array[4]
   0:Object
   1:Object
   2:Object
    editable:false
    key:"year"
    removeable:false
    value:"2000"
   3:Object
    editable:false
    key:"time"
    removeable:false
    value:"Day: TRUE, Night:False"
   4:Object
    editable:false
    key:"month"
    removeable:false
    value:"August"

视图是

 var viewModel = that.getView().getModel();
 var viewModelData = viewModel.getData();
 var systemModelData = system.getModelData();
 viewModel.setData($.extend(viewModelData, systemModelData));

//controll

//controll

createContent : function(oController) {
     return new sap.m.Table({
       columns: [
                new sap.m.Column({
                    header: new sap.m.Text({
                        text: 'key',
                    })
                }),
       items: {
                path: '/details',
                template: new sap.m.ColumnListItem({
                    cells: [
                        new sap.m.Text({
                            text: '{key}',
                        }),

我应该更改绑定路径以获取结果.或更改应在模型中进行.

Should I change the binding path to get the results. Or the change should be in the model.

推荐答案

您可以使用

You can use a filter to display only the month objects in the bound array:

createContent : function(oController) {
     return new sap.m.Table({
       columns: [
                new sap.m.Column({
                    header: new sap.m.Text({
                        text: 'key',
                    })
                }),
                new sap.m.Column({
                    header: new sap.m.Text({
                        text: 'value',
                    })
                }),
       items: {
                path: '/details',
                filters: [ new sap.ui.model.Filter("key","EQ","month") ], //only display months
                template: new sap.m.ColumnListItem({
                    cells: [
                        new sap.m.Text({
                            text: '{key}',
                        }),
                        new sap.m.Text({
                            text: '{value}',
                        }),

这篇关于如何基于json属性将项目绑定到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆