SAPUI5 中的个性化表 [英] Personalization table in SAPUI5

查看:46
本文介绍了SAPUI5 中的个性化表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了一个这个 举例,我想对着我玩.

I saw an this expamle, and I want to play it at me.

这是我的 xml 视图:

This is my xml view:

        <Panel>
            <content>
                <Button press="onPersoButtonPressed" class="btn editTable"></Button>
            </content>
        </Panel>
        <Table id="Listing" class="tableList" mode="MultiSelect" items="{path: 'masterData>/contactsList'}">
            <columns>
                <Column minScreenWidth="Tablet" demandPopin="true">
                    <Text text="{i18n>vendorNum}"/>
                </Column>
                <Column minScreenWidth="Tablet" demandPopin="true">
                    <Text text="{i18n>recipientType}"/>
                </Column>
                <Column minScreenWidth="Tablet" demandPopin="true">
                    <Text text="{i18n>eMail}"/>
                </Column>
            </columns>

            <items>
                <ColumnListItem>
                    <cells>
                        <Text text="{masterData>vendorNum}"/>
                    </cells>
                    <cells>
                        <Text text="{masterData>recipientType}"/>
                    </cells>
                    <cells>
                        <Text text="{masterData>eMail}"/>
                    </cells>
                </ColumnListItem>
            </items>
        </Table>

这是我的控制器:

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/ui/core/routing/History",
    "sap/ui/model/json/JSONModel",
    "sap/ui/test/controller/TopMenu.controller",
    "sap/m/TablePersoController",
    "sap/ui/model/resource/ResourceModel"
], function (Controller,History,JSONModel,TopMenu,ResourceModel,TablePersoController) {
    "use strict";
    jQuery.sap.require("sap.ui.core.util.Export");
    jQuery.sap.require("sap.ui.core.util.ExportTypeCSV");
return Controller.extend("sap.ui.test.controller.MasterData", {
    onInit : function () {
        var oData = {
            contactsList:[
                {
                    vendorNum: '101938',
                    recipientType: 'Promo',
                    supplierName: 'Company name'
                },
                {
                    vendorNum: '101936',
                    recipientType: 'Abcd',
                    supplierName: ''
                },
                {
                    vendorNum: '101933',
                    recipientType: 'Xyz',
                    supplierName: 'Comp.Name',
                    beCode: '0108'
                }
            ]
        };

        var oModel = new JSONModel(oData);
        this.getView().setModel(oModel, "masterData");
        var i18nModel = new ResourceModel({
            bundleName: "sap.ui.lenta.i18n.i18n"
        });
        this.getView().setModel(i18nModel, "i18n");

        this._oTPC = new TablePersoController({
            table: this.getView().byId("Listing"),
            componentName: "test"
        }).activate();
    },
    onPersoButtonPressed: function (oEvent) {
        this._oTPC.openDialog();
    },

    onTablePersoRefresh : function() {
        //DemoPersoService.resetPersData();
        this._oTPC.refresh();
    },

    onTableGrouping : function(oEvent) {
        this._oTPC.setHasGrouping(oEvent.getSource().getSelected());
    },

    //.....

该示例引发错误:未捕获的错误:ManagedObject sap.m.TablePersoController#__controller0 中不存在属性appDescription".在这种情况下,字符串 " description ":" {{app Description}} " 存在于 manifest.json 中,而描述字符串存在于 i18n.properties 中.

That example throwing an error: Uncaught Error: Property "appDescription" does not exist in ManagedObject sap.m.TablePersoController#__controller0. In this case, the string " description ":" {{app Description}} " present in manifest.json, and description string exist in i18n.properties.

我不知道我错过了什么?如何使此代码有效?或者我是否需要使用其他东西来解决表格列的操作问题?

I can not figure out what I missed? How to make that this code worked? Or do I need to use something else to solve the problem with the actions of the table-columns?

推荐答案

您创建了错误的对象名称与类名称的映射.

You created wrong mapping of object names with class names.

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/ui/core/routing/History",
    "sap/ui/model/json/JSONModel",
    "sap/ui/test/controller/TopMenu.controller",
    "sap/m/TablePersoController",
    "sap/ui/model/resource/ResourceModel"
], function (Controller,History,JSONModel,TopMenu,TablePersoController, ResourceModel) {
    "use strict";

这里 ResourceModel 对象应该与上面提到的 TablePersoController 互换.

Here ResourceModel object should be interchanged with TablePersoController as mentioned above.

因为 TablePersoController 指的是为 ResourceModel 提到的类,它不能正常工作.

Because TablePersoController was referring to class mentioned for ResourceModel, it was not properly working.

更改顺序,应该可以解决错误.

Change the order and the error should be resolved.

这篇关于SAPUI5 中的个性化表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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