【问题标题】:How to use smartfilterbar and smarttable?如何使用 smartfilterbar 和 smarttable?
【发布时间】:2018-07-11 07:35:57
【问题描述】:

我有 EntitySet 并想连接到 SmartFilterBarSmartTable。 EntitySet 看起来像:

<EntitySet Name="I_PMContactCardEmployee" EntityType="EAM_MALFUNCTION_MANAGE.I_PMContactCardEmployeeType" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:searchable="true" sap:content-version="1"/>   

实体类型:

<EntityType Name="I_PMContactCardEmployeeType" sap:label="Mitarbeiter" sap:content-version="1">
    <Key>
        <PropertyRef Name="PersonnelNumber"/>
    </Key>
    <Property Name="PersonnelNumber" Type="Edm.String" Nullable="false" MaxLength="8" sap:display-format="NonNegative" sap:text="EmployeeFullName" sap:label="Personalnummer"/>
    <Property Name="EmployeeFullName" Type="Edm.String" MaxLength="80" sap:label="Vollständiger Name" sap:filterable="false"/>
    <Property Name="FirstName" Type="Edm.String" MaxLength="40" sap:label="Vorname" sap:quickinfo="Vorname des Geschäftspartners (Person)"/>
    <Property Name="FamilyName" Type="Edm.String" MaxLength="40" sap:label="Nachname" sap:quickinfo="Nachname des Geschäftspartners (Person)"/>
    <Property Name="Job" Type="Edm.String" MaxLength="8" sap:display-format="NonNegative" sap:label="Stellenschlüssel" sap:quickinfo="Stelle" sap:filterable="false"/>
    <Property Name="JobName" Type="Edm.String" MaxLength="25" sap:label="Stellenbezeichnung" sap:filterable="false"/>
    <Property Name="CompanyCode" Type="Edm.String" MaxLength="4" sap:display-format="UpperCase" sap:text="CompanyCodeName" sap:label="Buchungskreis"/>
    <Property Name="CompanyCodeName" Type="Edm.String" MaxLength="25" sap:label="Name der Firma" sap:quickinfo="Buchungskreis- oder Firmen-Bezeichnung" sap:filterable="false"/>
    <Property Name="OrganizationalUnit" Type="Edm.String" MaxLength="8" sap:display-format="NonNegative" sap:label="Organisationseinheit"/>
    <Property Name="OrganizationalUnitName" Type="Edm.String" MaxLength="25" sap:label="OrgEinheitenkurztext" sap:quickinfo="Organisationseinheitenkurztext" sap:filterable="false"/>
    <Property Name="PhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefon" sap:quickinfo="Telefonnummer: Vorwahl+Anschluß" sap:filterable="false"/>
    <Property Name="NormalizedPhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefonnummer" sap:quickinfo="Vollständige Nummer: Vorwahl+Anschluß+Durchwahl" sap:filterable="false"/>
    <Property Name="MobilePhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefon" sap:quickinfo="Telefonnummer: Vorwahl+Anschluß" sap:filterable="false"/>
    <Property Name="MblNormalizedPhoneNumber" Type="Edm.String" MaxLength="30" sap:display-format="UpperCase" sap:label="Telefonnummer" sap:quickinfo="Vollständige Nummer: Vorwahl+Anschluß+Durchwahl" sap:filterable="false"/>
    <Property Name="DefaultEmailAddress" Type="Edm.String" MaxLength="241" sap:label="E-Mail-Adresse"/>
    <Property Name="UserID" Type="Edm.String" MaxLength="12" sap:display-format="UpperCase" sap:label="Benutzer-ID" sap:filterable="false"/>
</EntityType>

视图看起来像:

<smartFilterBar:SmartFilterBar id="smartFilterBar" entitySet="malfunc>I_PMContactCardEmployee" persistencyKey="SmartFilterPKey">
    <smartFilterBar:controlConfiguration>
        <smartFilterBar:ControlConfiguration key="PersonnelNumber" visibleInAdvancedArea="true" preventInitialDataFetchInValueHelpDialog="false"></smartFilterBar:ControlConfiguration>
    </smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<smartTable:SmartTable id="smartTable_ResponsiveTable" smartFilterId="smartFilterBarr" tableType="ResponsiveTable" editable="false"
    entitySet="malfunc>I_PMContactCardEmployee" useVariantManagement="true" useTablePersonalisation="true" header="Products" showRowCount="true"
    useExportToExcel="false" enableAutoBinding="true" persistencyKey="SmartTablePKey"></smartTable:SmartTable>

服务注册为:

    "models": {
        "i18n": {
            "type": "sap.ui.model.resource.ResourceModel",
            "settings": {
                "bundleName": "example.com.smartemployee.i18n.i18n"
            }
        },
        "malfunc": {
            "uri": "/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/",
            "type": "sap.ui.model.odata.v2.ODataModel",
            "settings": {
                "defaultOperationMode": "Server",
                "defaultBindingMode": "OneWay",
                "defaultCountMode": "Request"
            },
            "dataSource": "EAM_MALFUNCTION_MANAGE",
            "preload": true
        }
    },

从服务中获取数据,在postman我调用了:

并获得所有员工。

当我执行应用程序时,SmartFilterBarSmartTable 无法正常工作。

它只显示一个空的过滤器栏。我做错了什么?

【问题讨论】:

  • 你不必绑定 I_PMContactCardEmployeeSet 而不是 I_PMContactCardEmployee

标签: sapui5


【解决方案1】:

据我所知,最好将 ODataModel 定义为默认模型。

"malfunc": {
        "uri": "/sap/opu/odata/sap/EAM_MALFUNCTION_MANAGE/",
        "type": "sap.ui.model.odata.v2.ODataModel",
        "settings": {
            "defaultOperationMode": "Server",
            "defaultBindingMode": "OneWay",
            "defaultCountMode": "Request"
        },
        "dataSource": "EAM_MALFUNCTION_MANAGE",
        "preload": true
    }

另外,假设您的 EntitySet 名为“I_PMContactCardEmployeeSet”,您必须在 SmartFilterBar 和 SmartTable 属性中指定该 EntitSet:

entitySet="I_PMContactCardEmployeeSet"

【讨论】:

    猜你喜欢
    • 2017-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多