<?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: Dynamically adding UI controls after oModel read call completes in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446222#M4661122</link>
    <description>&lt;P&gt;It is still can be done by binding......just follow Thorsten's example&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;VBox items="{ColumnDynamic}"&amp;gt;&amp;lt;items&amp;gt;&amp;lt;Text text="{mytext}"/&amp;gt; &amp;lt;items&amp;gt;&lt;BR /&gt;&amp;lt;/VBox&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;compose this kind of structure in your jsonmodel&lt;/P&gt;&lt;P&gt;ColumnA,&lt;/P&gt;&lt;P&gt;ColumnB&lt;/P&gt;&lt;P&gt;ColumnC&lt;/P&gt;&lt;P&gt;ColumnDynamic:[{mytext:"yourtext"}............]&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Jul 2021 17:35:08 GMT</pubDate>
    <dc:creator>junwu</dc:creator>
    <dc:date>2021-07-12T17:35:08Z</dc:date>
    <item>
      <title>Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaq-p/12446217</link>
      <description>&lt;P&gt;Hello Community experts,&lt;/P&gt;
  &lt;P&gt;I have a sap.ui.table.Table that is bound to JSONModel retrieved from an odata read call. One of the columns in the table needs to be dynamically generated after the oModel read call completes so that I can traverse through the array returned from it, build a VBox of sap.m.Text controls and fill it with data received in the array. (I can't this do this with binding because I need to fetch data from multiple different arrays returned in the odata call). The issue is, I can't use methods like onBefore or onAfterRendering because of the asynchronous nature of the odata call as the data is undefined still when those get executed. I have tried using the attachRequestCompleted method to try to do it there, but it doesn't render the content I am adding. Here is the method code in the onInit() method of the controller.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;this._oModel.attachRequestCompleted(function(oEvent) {
                var oView = this.getView();                
                var oData = this._oData; // from the oModel.read() call
                var commentsSection = oView.byId("commentsVBox");            
                    commentsSection.insertItem(new sap.m.Text({
                        text: oData.results[0].comment
                }));     
            }, this);
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I've tried the above code in all 3 methods; onInit(), onBeforeRendering() and onAfterRendering(). None of these worked. So far for testing i just inserted on Text item, but the plan was to iterate an array and inserts as many per line item as needed. Does anyone know how I may achieve this? Is this the wrong way to go about it?&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 07:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaq-p/12446217</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T07:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446218#M4661118</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;dngo&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;try to use the model to bind text elements like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;VBox items="{/MyItems}"&amp;gt;

 &amp;lt;items&amp;gt;
  &amp;lt;Text text="{mytext}"/&amp;gt; 
&amp;lt;items&amp;gt;&lt;BR /&gt;&amp;lt;/VBox&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 12:03:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446218#M4661118</guid>
      <dc:creator>ThorstenHoefer</dc:creator>
      <dc:date>2021-07-12T12:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446219#M4661119</link>
      <description>&lt;P&gt;if you are using jsonmodel for the table, then it is more than possible that you can do it through binding.&lt;/P&gt;&lt;P&gt;do the binding like other column,  after odata call, just put the data into the correct place of the jsonmodel&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 14:56:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446219#M4661119</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T14:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446220#M4661120</link>
      <description>&lt;P&gt;Hello Thorsten,&lt;/P&gt;&lt;P&gt;Thanks for the response. I cannot use binding (or can't think of a way it would work in my scenario), because the data comes from multiple nested arrays that I need to iterate through first. What I am trying is then adding the sap.m.Text ui controls to the ui after the odata call is made depending on the amount of line items returned in the nested arrays.&lt;/P&gt;&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 16:06:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446220#M4661120</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T16:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446221#M4661121</link>
      <description>&lt;P&gt;Jun,&lt;/P&gt;&lt;P&gt;The column won't have just one ui control to bind the data to. The amount of sap.m.Text controls I want to insert into the column depends on the data retrieved after the odata call. If the array returned has 3 items for example. I am trying to insert 3 sap.m.Text's into the column for that specific row in the table. &lt;/P&gt;&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 16:09:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446221#M4661121</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T16:09:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446222#M4661122</link>
      <description>&lt;P&gt;It is still can be done by binding......just follow Thorsten's example&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;VBox items="{ColumnDynamic}"&amp;gt;&amp;lt;items&amp;gt;&amp;lt;Text text="{mytext}"/&amp;gt; &amp;lt;items&amp;gt;&lt;BR /&gt;&amp;lt;/VBox&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;compose this kind of structure in your jsonmodel&lt;/P&gt;&lt;P&gt;ColumnA,&lt;/P&gt;&lt;P&gt;ColumnB&lt;/P&gt;&lt;P&gt;ColumnC&lt;/P&gt;&lt;P&gt;ColumnDynamic:[{mytext:"yourtext"}............]&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 17:35:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446222#M4661122</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T17:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446223#M4661123</link>
      <description>&lt;P&gt;Sorry Jun, none of what you typed above is making any sense to me. What is ColumnDynamic? And did you insert a Text control into the items property of the VBox? Is that possible? Would you be able to post a working example?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 17:48:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446223#M4661123</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T17:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446224#M4661124</link>
      <description>&lt;P&gt;those are just attribute name in your jsonmodel....&lt;/P&gt;&lt;P&gt;ColumnA,&lt;/P&gt;&lt;P&gt;ColumnB&lt;/P&gt;&lt;P&gt;ColumnC&lt;/P&gt;&lt;P&gt;ColumnDynamic&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 17:50:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446224#M4661124</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T17:50:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446225#M4661125</link>
      <description>&lt;P&gt;dude,&lt;/P&gt;&lt;P&gt;ColumnDynamic:[{mytext:"yourtext"}............] it is array, it will rendner multiple text for you.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 18:49:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446225#M4661125</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T18:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446226#M4661126</link>
      <description>&lt;P&gt;Jun,&lt;/P&gt;&lt;P&gt;the odata received from the read call get bound to the view as so&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;this.getView().setModel(new JSONModel(odata), "myModel");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then in the table I have this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;Table rows="{ path: 'myModel&amp;gt;/results'}"&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in the odata itself i have nested arrays like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;odata: {
    results: [
        {
            data1: value,

            data2: value,

            results: [

                data1: value,
                data2: value,

                results: [
                    // more data could have more nesting
                ]
            ]
        },

        {
            results: [

                data1: value,
                data2: value
            ]
        },
    ]
}&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Are you saying that I can get the nested array data and push that data into a custom array and then push that custom array into the first level of the odata structure and then bind that array to the UI control in the table?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 21:57:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446226#M4661126</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T21:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446227#M4661127</link>
      <description>&lt;P&gt;yes........&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:14:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446227#M4661127</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T22:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446228#M4661128</link>
      <description>&lt;P&gt;Do you have any examples of how to push the custom array into the odata model? So lets say I have created my custom array:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var arrCustom = [{data: val, data: val}, {data: val, data: val}, {data: val, data: val} ];&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Once I have that I can push this into the oModel?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;var myData = this.getView().getModel("myModel");
myData.results[25].push(arrCustom); // this is allowed?
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:18:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446228#M4661128</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T22:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446229#M4661129</link>
      <description>&lt;P&gt;youfirstlevelobject.yourattributename=yourdataarray&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:21:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446229#M4661129</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T22:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446230#M4661130</link>
      <description>&lt;P&gt;didn't work.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;myData.results=arrCustom;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:53:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446230#M4661130</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T22:53:00Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446231#M4661131</link>
      <description>&lt;P&gt;can't you debug.....&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;myData.results[25] what is this pointing to? doesn't look like array, why you use push?????&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Jul 2021 22:58:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446231#M4661131</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T22:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446232#M4661132</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;myData.results[25]&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is the 24th element of the array AKA the 25th row of the table. Each element of the results array is a row in the table. Nested deep inside each element are additional arrays which contain data that needs to be bound to a specific column. From what I understand you're saying, is that I can fetch the data from these nested arrays and collect them in a custom array. Then I can attach this custom array to the first level results array which is bound to the table and columns using the above syntax (which doesn't work). &lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 23:11:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446232#M4661132</guid>
      <dc:creator>former_member718482</dc:creator>
      <dc:date>2021-07-12T23:11:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically adding UI controls after oModel read call completes</title>
      <link>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446233#M4661133</link>
      <description>&lt;P&gt;if I understand you correctly&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;myData.results[25].columnDynamic=arrCustom&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;if you keep writing wrong code, how can it be working.......&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jul 2021 23:15:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/dynamically-adding-ui-controls-after-omodel-read-call-completes/qaa-p/12446233#M4661133</guid>
      <dc:creator>junwu</dc:creator>
      <dc:date>2021-07-12T23:15:12Z</dc:date>
    </item>
  </channel>
</rss>

