cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5 Table Binding with Navigation Link in the Master-Detail HCP Template

janwerder
Explorer
0 Kudos

Dear Experts,

I'm trying to use a Navigation Link for binding data to a table in the Master-Detail Template for SAP UI5. To understand my problem, let me introduce you to my solution thus far:

I have an OData 2.0 Service designed in the Gateway which offers me the following service:

To summarize I have a central Service which links to two Entities via two Navigation Links. I designed it this way to have "table-in-table" datastructure in the end. In theory this works very well and even when testing it in the browsers I didn't encounter any problems. But the next step is where it gets difficult.

So I generated my Master-Detail Project via the HCP, but I'm editing it locally. Since I want to make a Fiori Application the views are XML-based. The goal is to show all contents of the DumpTabelleSet in the Detail view (which works great!) and to have a table with the contents of both of the two linked Entities on the page as well. Since the template does some Model-Binding-Magic behind the scenes in the controller, I access the contents of the DumpTabelleSet by using a direct reference.

  

<ObjectHeader id="objectHeader" title="Dump-Typ: {Dumpid}" numberUnit="{Syuser}">

But the problems arise when I want to use the entities from the Nnvigation link. So far I have this piece of code:

  <Table items="{path: 'VersionsTabelleSet>/'}">
               <columns>
                      <Column>
                            <header>
                                  <Label text="Header 1" id="__label0"/>
                             </header>
                      </Column>
             </columns>
             <items>
                 <ColumnListItem>
                       <cells>
                           <Text text="{HostKuerzel}" />
                       </cells>
                  </ColumnListItem>
           </items>
   </Table>

But that results in a simple "No Data" output inside of the table.

I would be very grateful for any recommendations!

Thanks in advance,

Jan

Accepted Solutions (1)

Accepted Solutions (1)

janwerder
Explorer
0 Kudos

So I found the answer to my problem using the SAP Web IDE with it's OData Service Discovery features.The following code works in my example:

<Table items="{DumpVersionsNav}">

  <columns>

        <Column>

            <Text text="Hostkuerzel"/>

        </Column>

</columns>

<items>

    <ColumnListItem>

        <cells>

            <ObjectNumber

            unit="{Hostkuerzel}"/>

        </cells>

    </ColumnListItem>

</items>

</Table>

By using the Navigation Link in the items attribute of the table, SAP UI5 knows how to find the set behind that.

After setting it right, you can easily access all of the attributes of the set by just using their name.

This effectively allows table-in-table data structures, which is great in case you have complex data structures to work with.

Answers (3)

Answers (3)

SergioG_TX
Active Contributor
0 Kudos

seems like you are using a named model and you are missing the end point. 

if so, then make sure you have :    on your table binding... path: 'nameModel>/ENDPOINT'

then in the column cells binding .... you should have     'nameModel>COLNAME'

hope this help

janwerder
Explorer
0 Kudos

Well, that would change my code to this, I believe:

  <Table items="{path: 'detailView>/VersionsTabelleSet'}">

             <columns>

            <Column>

                       <header>

                 <Label text="Header 1" id="__label0"/>

                   </header>

            </Column>

           </columns>

           <items>

    <ColumnListItem>

        <cells>

            <Text text="{detailView>/HostKuerzel}" />

        </cells>

    </ColumnListItem>

</items>

  </Table>

But it then throws me an error:

"Resource for segment ''&gt;'' not found"

"'&gt;' stands for the greater sign and it actually throws me that error twice, once for the path and once for the column, I think.

The name of the model should be accurate, since the _onMetadataLoaded function loads it via oViewModel = this.getModel("detailView");

SergioG_TX
Active Contributor
0 Kudos

for your table... use this:

<Table items="{detailView>/VersionsTabelleSet}" >

for your cells, use this:

<Text text="{detailView>HostKuerzel}" />

I think you just have an extra / ---

hope this works now

janwerder
Explorer
0 Kudos

Well, this resolved the error in the console, but there is still no data being displayed. Do you need any further information?

What would be an alternative? A second model?

SergioG_TX
Active Contributor
0 Kudos

I think the issue may be with the path to your end point. make sure you have set the model, also that you can see the data and that the endpoint is correctly spelled.

do you see data in the model? if so, what is the structure. that should give you an idea of what is incorrect.

janwerder
Explorer
0 Kudos

I'm afraid I can't see any data, since it's an OData Model not a JSON Model. All Endpoints are correct, but what wonders me is that I haven't mentioned the navigation links anywhere. I should specify them if I want to use them, shouldn't I?

SergioG_TX
Active Contributor
0 Kudos

you should see the odata model or json model both.. in your odata service.. right click, run as xs service.. it should open your browser with the end points.. once there you should see the end point you are looking for.. then you can debug whether or not the data is being returned from your service

saivellanki
Active Contributor
0 Kudos

Hi Jan,

Can you share model definition (like how you're setting the model) also the screenshot of model response.

Regards,

Sai Vellanki.

janwerder
Explorer
0 Kudos

Hi Sai,

Like mentioned above I use the standard template for master-detail from the SAP HCP Web IDE.

When navigating to a DetailView, which is the case here, it calls the _showDetail Function:

   _showDetail : function (oItem) {
   var bReplace = !Device.system.phone;
   this.getRouter().navTo("object", {
   objectId : oItem.getBindingContext().getProperty("Dumpkey")
   }, bReplace);
   },

With the model response you mean a XML repsonse from the Odata service? If so, a Query or a Read?

former_member183518
Active Participant
0 Kudos

Try providing the path for the table as items="{VersionsTabelleSet}" .

janwerder
Explorer
0 Kudos

I'm afraid that didn't solve the problem. I am getting a "Resource for segment 'VersionsTabelleSet' not found" error in console though. But that seems like a very generic error when a databinding against an odata service just doesn't work.

Additionally I'm not sure if it works that way. The VersionsTabelleSet has to be called with the specific key (Dumpkey), which is automatically set when clicking on an Item in the MasterView. I think this because I can access the properties of DumpTabelleSet by just writing the property names (i.e. Dumpid) and not the full OData Path(ie. DumpTabelleSet('<mykeyhere>')/Dumpid). But when is assertion is true, the Navigation via just writing VersionsTabelleSet wouldn't use the key, I believe.