Personalization table in SAPUI5

我怕爱的太早我们不能终老 提交于 2019-12-25 18:42:51

问题


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

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>

And this is my controller:

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());
    },

    //.....

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?


回答1:


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";

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

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

Change the order and the error should be resolved.



来源:https://stackoverflow.com/questions/35984224/personalization-table-in-sapui5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!