Skip to Content
avatar image
Former Member

UI5 path to parent property

Hi,

I have an application which has Header (from oData) binded to screen, table with Items with relative path "items". All of that is done in XML file, how can I get there a path in item level to parent? I mean I want to bind for item some property from header

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Oct 17, 2016 at 11:13 AM

    directly its not possible.

    you need to create a named model and set this model to view/core, and then you will able to use header data using model name, something like below:

    var oModel = new sap.ui.model.json.JSONModel(your header data here);    
    this.getView().setModel(oModel,"HeaderDataModel");
    // and then you can use header data anywhere in the view using "HeaderDataModel"
    
    <button enabled ="{HeaderDataModel>/HeaderAttr2}">

    Hope this will help you.

    Regards,

    Akhilesh

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2016 at 07:06 AM

    Just set the binding path to the header property.

    Here is an example in which I show a property even from another model just by defining the respective path

    <m:Table id="idProductsTable" inset="false" items="{pdfs>/pdfs}">
      <m:columns>
        <m:Column>
          <m:Text text="note"/>
        </m:Column>
        <m:Column minScreenWidth="Tablet" demandPopin="true">
          <m:Text text="mobile phone"/>
        </m:Column>
      </m:columns>
      <m:items>
        <m:ColumnListItem>
          <m:cells>
            <m:ObjectIdentifier text="{pdfs>note}"/>
            <m:Link text="{Phone/Mobile}" target="_blank" href="{pdfs>url}"/>
          </m:cells>
        </m:ColumnListItem>
      </m:items>
    </m:Table>

    In this example I use even a property from another model inside my table. The table items is bound to "pdfs>/pdfs" whereas the mobile phone column is bound to "/Phone/Mobile" of the views default model.

    Note: It's always easier to understand your problem if you add some sample coding to your questions.

    Regards Helmut

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2016 at 03:51 AM

    Hi Adam,

    Did you check this thread? OData 'expand' parameters

    Regards,

    Sai.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2016 at 10:43 AM

    Hi Adam- You can follow the below steps.

    1. Bind data from odata to json model.
    2. Use bind property to display required entity
    3. ex: sap.m.Text().bindproperty("text", "JSONModel>/UserCollection/UserId(1)").

    Regards,

    Karthik A

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 14, 2016 at 06:19 PM

    Here is the situation:

    Controller before rendering binds Header to view. I have in table relation in items as relative path "{items}" (navigation property from header to items). So now I would like to have access in item level to Header properties.

    <label id="label1" value="{HeaderAttr1}>

    <Table items="{items}>
    ...
    <items>
    ...
    <button enabled ="{HeaderAttr2}">

    HeaderAttr2 - doesn't work, just like: /../HeaderAttr2, ../HeaderAttr2

    My problem in comparing to Helmut code is that my Header is binded to a view by controller, so HeaderAttr1 works in label, but I don't know how to access data from item to those attributes.
    I'm looking for nice, clear way.

    Add comment
    10|10000 characters needed characters exceeded