<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: UI5 data binding question in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604240#M4727220</link>
    <description>&lt;P&gt;Thank you for your reply and the github demo solution. I will try it out and come back with an answer.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Sep 2022 10:05:33 GMT</pubDate>
    <dc:creator>trmt</dc:creator>
    <dc:date>2022-09-22T10:05:33Z</dc:date>
    <item>
      <title>UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaq-p/12604235</link>
      <description>&lt;P&gt;Hello �� &lt;/P&gt;
  &lt;P&gt;I started learning UI5 and I'm having a bit of trouble with data binding. &lt;/P&gt;
  &lt;P&gt;Let's say I have a list of directors: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;directors.json
[
   {
      "directorID":1,
      "name":"Christopher Nolan",
      "age":52,
      "location":"London",
      "oscars":5
   },
   {
      "directorID":2,
      "name":"Quentin Tarantino",
      "age":59,
      "location":"United States",
      "oscars":8
   }
]&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;That I will display in a list.&lt;/P&gt;
  &lt;P&gt;On clicking a certain &lt;EM&gt;director &lt;/EM&gt;I would like to take the user to another page, basically another list that will show the &lt;EM&gt;movies&lt;/EM&gt; of this &lt;EM&gt;director. &lt;/EM&gt;These &lt;EM&gt;movies&lt;/EM&gt; will be taken from another &lt;EM&gt;.json &lt;/EM&gt;file that has a few entries with the &lt;EM&gt;directorID &lt;/EM&gt;as the common key between the two: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;strong&amp;gt;movies.json&amp;lt;/strong&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&amp;lt;strong&amp;gt;[
   {
      "directorID":1,
      "movieID":1,
      "name":"Inception",
      "year":2010,
      "mainCharacter":"Leonardo Di Caprio"
   },
   {
      "directorID":1,
      "movieID":2,
      "name":"Interstellar",
      "year":2014,
      "mainCharacter":"Matthew McConaughey"
   },
   {
      "directorID":1,
      "movieID":3,
      "name":"Tenet",
      "year":2020,
      "mainCharacter":"John David Washington"
   },
   {
      "directorID":2,
      "movieID":4,
      "name":"Pulp Fiction",
      "year":1994,
      "mainCharacter":"John Travolta"
   },
   {
      "directorID":2,
      "movieID":5,
      "name":"Inglourious Basterds",
      "year":2009,
      "mainCharacter":"Brad Pitt"
   },
   {
      "directorID":2,
      "movieID":6,
      "name":"Django",
      "year":2012,
      "mainCharacter":"Jamie Foxx"
   }
]&amp;lt;/strong&amp;gt;&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;What would be the best to way to filter the results on the second list based on the argument passed in the route: &lt;EM&gt;.../directors/{directorID}?&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;As of now, I could send from &lt;EM&gt;navTo &lt;/EM&gt;and capture the &lt;EM&gt;directorID &lt;/EM&gt;in &lt;EM&gt;_onRouteMatched &lt;/EM&gt;via the &lt;EM&gt;getParameter &lt;/EM&gt;method, but after this I'm a bit stuck. &lt;/P&gt;
  &lt;P&gt;I also searched for a sample to see this technique in action but I couldn't find any, some recommendation on this would also be appreciated. &lt;/P&gt;
  &lt;P&gt;Thanks&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;edit: The code that I'm asking about is found here: &lt;A href="https://plnkr.co/edit/0WI2yiG56Nzspk0l" target="test_blank"&gt;https://plnkr.co/edit/0WI2yiG56Nzspk0l&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 10:31:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaq-p/12604235</guid>
      <dc:creator>trmt</dc:creator>
      <dc:date>2022-09-14T10:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604236#M4727216</link>
      <description>&lt;P&gt;I think you got it, it just would be /movies/{directorID} since you want to display the movies for a particular director.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 12:43:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604236#M4727216</guid>
      <dc:creator>Tukutupap</dc:creator>
      <dc:date>2022-09-14T12:43:11Z</dc:date>
    </item>
    <item>
      <title>Re: UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604237#M4727217</link>
      <description>&lt;P&gt;That is not the problem I have.&lt;/P&gt;&lt;P&gt;The thing is I don't know how to query the right data to show in the Movies view once the director was pressed in the list. &lt;/P&gt;&lt;P&gt;This is the code: &lt;A href="https://plnkr.co/edit/0WI2yiG56Nzspk0l" target="test_blank"&gt;https://plnkr.co/edit/0WI2yiG56Nzspk0l&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Can you please give me a hint where in the Movies.controller.js &amp;amp; how this filtering of movies based on director's id should be done? &lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 14:35:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604237#M4727217</guid>
      <dc:creator>trmt</dc:creator>
      <dc:date>2022-09-14T14:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604238#M4727218</link>
      <description>&lt;P&gt;I'm sorry, but for some reason I cant reach that page. Must have something to do with my company's policy maybe. I tried to take a peak on my phone but it was pretty bad.&lt;/P&gt;&lt;P&gt;Anyways, I don't think you need to do anything in your controller, your OData model takes care. You just need to build the corresponding association/navigation between your movies and your directors. You do that in your OData service in your backend, the rest happens automagically.&lt;/P&gt;&lt;P&gt;So again, no code. Just make sure your next panel has the right binding according to the navigation you have built. So an example would be "/directors/{directorId}/movies".&lt;/P&gt;&lt;P&gt;Check &lt;A href="https://blogs.sap.com/2014/09/24/lets-code-associationnavigation-and-data-provider-expand-in-odata-service/" target="_blank"&gt;this&lt;/A&gt; out.&lt;/P&gt;&lt;P&gt;Kr,&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 13:48:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604238#M4727218</guid>
      <dc:creator>Tukutupap</dc:creator>
      <dc:date>2022-09-15T13:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604239#M4727219</link>
      <description>&lt;P&gt;I guess one thing you need to be aware of is that the "default" model of the app is of type ODataModel (v2), so you either filter directly against this mock OData service (using OData methods) or convert your ODataModel to a local JSONModel. You can find a demo solution based on your code &lt;A href="https://github.com/HymanZHAN/ui5-data-binding" target="_blank"&gt;here on my Github&lt;/A&gt;, but essentially you can do the following in your Movies.controller.js:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sap.ui.define(&lt;BR /&gt;  ["directors/movies/controller/BaseController", "sap/ui/model/json/JSONModel"],&lt;BR /&gt;  function (BaseController, JSONModel) {&lt;BR /&gt;    "use strict";&lt;BR /&gt;&lt;BR /&gt;    return BaseController.extend("directors.movies.controller.Movies", {&lt;BR /&gt;      onInit: function () {&lt;BR /&gt;        const oRouter = this.getRouter();&lt;BR /&gt;        oRouter&lt;BR /&gt;          .getRoute("moviesList")&lt;BR /&gt;          .attachMatched(this._onRouteMatched, this);&lt;BR /&gt;      },&lt;BR /&gt;&lt;BR /&gt;      _onRouteMatched: function (oEvent) {&lt;BR /&gt;        // save the current query state&lt;BR /&gt;        let oArgs, oView;&lt;BR /&gt;        oArgs = oEvent.getParameter("arguments");&lt;BR /&gt;        oView = this.getView();&lt;BR /&gt;&lt;BR /&gt;        oView.getModel().read("/Movies", {&lt;BR /&gt;          method: "GET",&lt;BR /&gt;          success: function (oData) {&lt;BR /&gt;            console.log("Read success!");&lt;BR /&gt;            console.log("oData.results:", oData.results);&lt;BR /&gt;            const oJsonModel = new JSONModel();&lt;BR /&gt;            const movies = oData.results.filter(&lt;BR /&gt;              (m) =&amp;gt; m.DirectorID == oArgs.DirectorID&lt;BR /&gt;            );&lt;BR /&gt;            console.log("movies: ", movies);&lt;BR /&gt;            oJsonModel.setData({ movies });&lt;BR /&gt;            oView.setModel(oJsonModel, "viewModel");&lt;BR /&gt;          },&lt;BR /&gt;        });&lt;BR /&gt;      },&lt;BR /&gt;    });&lt;BR /&gt;  }&lt;BR /&gt;);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Sep 2022 15:22:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604239#M4727219</guid>
      <dc:creator>xucong_zhan</dc:creator>
      <dc:date>2022-09-15T15:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: UI5 data binding question</title>
      <link>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604240#M4727220</link>
      <description>&lt;P&gt;Thank you for your reply and the github demo solution. I will try it out and come back with an answer.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Sep 2022 10:05:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/ui5-data-binding-question/qaa-p/12604240#M4727220</guid>
      <dc:creator>trmt</dc:creator>
      <dc:date>2022-09-22T10:05:33Z</dc:date>
    </item>
  </channel>
</rss>

