如何在“扩展"上使用多个属性列表组件中的参数 [sapui] [英] How use multiples properties on "expand" parameter in List component [sapui]

查看:47
本文介绍了如何在“扩展"上使用多个属性列表组件中的参数 [sapui]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 sap.m.List 组件,其中调用 OData 对象列表.这个对象里面有其他对象.出于这个原因,我使用 expand 参数来访问实习生对象的属性.但是当我在expand"参数上放置多个对象时,列表组件不起作用:

I have a sap.m.List component where invoke a list of OData objects. This object have others object inside it. For this reason, I use expand parameter for accessing to propertis of intern object. But when I put multiples objects on "expand" parameter, list component doesn't work:

这种方法行不通:

<List id="lstRequest" headerText="Custom Content"  
      items="{
                path: '/Requests',
                parameters: {
                   expand: ['RequestTypeDetails', 'UsersDetails']
                }
              }" 
>
    <StandardListItem
        title="{RequestTypeDetails/RequestType2} - {RequestCode}"
        description="{TotalAdvance}"
        icon="sap-icon://request"
        iconDensityAware="false"
        iconInset="false"
        type="Navigation"
        press="onSelectApprovation"  />
</List>

这种方式有效:

<List id="lstRequest" headerText="Custom Content"  
      items="{
                path: '/Requests',
                parameters: {
                   expand: 'RequestTypeDetails'
                }
              }" 
>
    <StandardListItem
        title="{RequestTypeDetails/RequestType2} - {RequestCode}"
        description="{TotalAdvance}"
        icon="sap-icon://request"
        iconDensityAware="false"
        iconInset="false"
        type="Navigation"
        press="onSelectApprovation"  />
</List>

当我需要在expand"参数上使用多个对象时,我不知道有多具体.

I don't know how especific when I need to use multiples objets on "expand" parameter.

感谢您的帮助!

更新 1

为@Nabi 提供的解决方案看起来有效......但我不安全,因为我在详细信息页面上调用列表元素.

The solution give for @Nabi looks working...But I'm not secure because I call elements of list on a detail page.

我用列表元素创建了一个 JSONModel 对象,然后在详细信息页面上调用这个对象:

I create a JSONModel object with element of list and then invoke this object on detail page:

var itemJSONModel = new JSONModel(itemObject, false);

this.setModel(itemJSONModel, "detailView");

但在我的详细信息页面中,我看不到 UsersDetails 属性的值(Users 是项目对象内的一个对象.UsersDeails 是 NavigationProperty 的名称):

But in my detail page I can't see value of UsersDetails properties (Users is an object inside item object. UsersDeails is the name of NavigationProperty):

<Input fieldGroupIds="datos_suscripcion" value="{detailView>/UsersDetails/UserName}"
                       placeholder="Usuario..." 
                       id="inUsuario"/>

编辑 2

这是 item 对象的 OData 模型:

This is OData model of item object:

<EntityType Name="Request">
<Key>
<PropertyRef Name="Id"/>
</Key>
<Property Name="AirTicketBuyer" Type="Edm.String" Nullable="true" MaxLength="50"/>
<Property Name="AirTicketBuyerEmail" Type="Edm.String" Nullable="true" MaxLength="50"/>
<Property Name="BusTicketBuyer" Type="Edm.String" Nullable="true" MaxLength="50"/>
<Property Name="BusTicketBuyerEmail" Type="Edm.String" Nullable="true" MaxLength="50"/>
<Property Name="CostCenter" Type="Edm.Int32" Nullable="false"/>
<Property Name="Created" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Currency" Type="Edm.Int32" Nullable="false"/>
<Property Name="Department" Type="Edm.Int32" Nullable="false"/>
<Property Name="DepartureDate" Type="Edm.DateTime" Nullable="false"/>
<Property Name="DepartureRoute" Type="Edm.String" Nullable="false" MaxLength="100"/>
<Property Name="DepartureTransportationType" Type="Edm.String" Nullable="false" MaxLength="1"/>
<Property Name="Destination" Type="Edm.String" Nullable="false" MaxLength="128"/>
<Property Name="DestinationType" Type="Edm.String" Nullable="false" MaxLength="1"/>
<Property Name="ExpirationDate" Type="Edm.DateTime" Nullable="false"/>
<Property Name="Id" Type="Edm.Int32" Nullable="false"/>
<Property Name="IdApplicant" Type="Edm.Int32" Nullable="true"/>
<Property Name="IdCompany" Type="Edm.Int32" Nullable="false"/>
<Property Name="IdUser" Type="Edm.Int32" Nullable="false"/>
<Property Name="Reason" Type="Edm.String" Nullable="false" MaxLength="200"/>
<Property Name="RequestCode" Type="Edm.String" Nullable="false" MaxLength="15"/>
<Property Name="RequestFatherId" Type="Edm.Int32" Nullable="true"/>
<Property Name="RequestStatus" Type="Edm.Int32" Nullable="false"/>
<Property Name="RequestType" Type="Edm.Int32" Nullable="false"/>
<Property Name="ReturnDate" Type="Edm.DateTime" Nullable="false"/>
<Property Name="ReturnRoute" Type="Edm.String" Nullable="false" MaxLength="100"/>
<Property Name="ReturnTransportationType" Type="Edm.String" Nullable="false" MaxLength="1"/>
<Property Name="SapCodeApplicant" Type="Edm.String" Nullable="true" MaxLength="6"/>
<Property Name="SapCodeUser" Type="Edm.String" Nullable="true" MaxLength="6"/>
<Property Name="StartFlowDate" Type="Edm.DateTime" Nullable="false"/>
<Property Name="TipoReq" Type="Edm.String" Nullable="true" MaxLength="2"/>
<Property Name="TotalAdvance" Type="Edm.Decimal" Nullable="false" Precision="12" Scale="2"/>
<NavigationProperty Name="ApprovalsRequestDetails" Relationship="rva-persistence.ApprovalsRequest_Request_Many_ZeroToOne0" FromRole="Request" ToRole="ApprovalsRequest"/>
<NavigationProperty Name="CostCenterDetails" Relationship="rva-persistence.Request_CostCenter_Many_ZeroToOne0" FromRole="Request" ToRole="CostCenter"/>
<NavigationProperty Name="CurrencyDetails" Relationship="rva-persistence.Currency_Request_One_Many0" FromRole="Request" ToRole="Currency"/>
<NavigationProperty Name="DepartmentDetails" Relationship="rva-persistence.Department_Request_One_Many0" FromRole="Request" ToRole="Department"/>
<NavigationProperty Name="ExpenseAdvanceDetails" Relationship="rva-persistence.ExpenseAdvance_Request_Many_ZeroToOne0" FromRole="Request" ToRole="ExpenseAdvance"/>
<NavigationProperty Name="CompanyDetails" Relationship="rva-persistence.Company_Request_One_Many0" FromRole="Request" ToRole="Company"/>
<NavigationProperty Name="UsersDetails" Relationship="rva-persistence.Users_Request_One_Many0" FromRole="Request" ToRole="Users"/>
<NavigationProperty Name="PassengerDetails" Relationship="rva-persistence.Passenger_Request_Many_ZeroToOne0" FromRole="Request" ToRole="Passenger"/>
<NavigationProperty Name="ReportDocumentDetails" Relationship="rva-persistence.ReportDocument_Request_Many_ZeroToOne0" FromRole="Request" ToRole="ReportDocument"/>
<NavigationProperty Name="RequestStatusDetails" Relationship="rva-persistence.Request_RequestStatus_Many_ZeroToOne0" FromRole="Request" ToRole="RequestStatus"/>
<NavigationProperty Name="RequestTypeDetails" Relationship="rva-persistence.RequestType_Request_One_Many0" FromRole="Request" ToRole="RequestType"/>
</EntityType>

推荐答案

使用简单的逗号分隔字符串:

Use a simple comma separated string:

<List 
    id="lstRequest"
    headerText="Custom Content"  
    items="{
        path: '/Requests',
        parameters: {
            expand: 'RequestTypeDetails,UsersDetails'
        }
    }" 
>

这篇关于如何在“扩展"上使用多个属性列表组件中的参数 [sapui]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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