Sap.m.Table中的数据绑定

时间:2015-09-02 10:59:26

标签: sapui5

我正在尝试使用sap.m.table

绑定一些过滤后的数据

模特我正在使用

var model = new sap.ui.model.json.JSONModel("../services/myexp.xsodata/ExpenseItem?$format=json&$filter=Expense_Claim_No eq "+id, false);
    console.log(model);
    sap.ui.getCore().setModel(model,'myitem');

模型以json格式返回数据

{
d: {
results: [
{
__metadata: {//some info
},
Expense_Item_No: 11011,
Expense_Claim_No: 1101,
Expense_Item_Description: "Taxi",
Expense_Amount: 800,
Expense_Item_Category: "Travel"
},
{
__metadata: {//some info
},
Expense_Item_No: 11012,
Expense_Claim_No: 1101,
Expense_Item_Description: "Meals",
Expense_Amount: 1200,
Expense_Item_Category: "Daily Expenses"
}
]
}
}

我的sap.m.Table代码

var aColumns = [
        new sap.m.Column({
            header : new sap.m.Label({
                text : "Expense Item No"
            })
        }),
        new sap.m.Column({
            header : new sap.m.Label({
                text : "Description"
            })
        }),
        new sap.m.Column({
            header : new sap.m.Label({
                text : "Category"
            })
        }),
        new sap.m.Column({
        header : new sap.m.Label({
            text : "Amount"
        }),
    })
    ];

var oTemplate = new sap.m.ColumnListItem({
    cells : [
        new sap.m.Text({
            text : "{Expense_Item_No}",
            wrapping : false
        }),
        new sap.m.Text({
            text : "{Expense_Item_Description}",
            wrapping : false
        }),
        new sap.m.Text({
            text : "{Expense_Item_Category}"
        }), 
        new sap.m.Text({
            text : "{Expense_Amount}"
        })
    ]
});
var oTable = new sap.m.Table({
    columns : aColumns
});
oTable.bindItems("myitem>/", oTemplate);

但它没有在桌子上显示数据。我究竟做错了什么。 请帮忙。谢谢

1 个答案:

答案 0 :(得分:1)

尝试

oTable.bindItems("myitem>/d/results", oTemplate);