如何使用smartfilterbar和smarttable?

时间:2018-07-11 07:35:58

标签: sapui5

我有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:

<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中:

enter image description here

并获得所有员工。

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

enter image description here

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

1 个答案:

答案 0 :(得分: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"