javascriptjqueryhtmloracle-jet

Hide a div in Oracle-jet


I am creating an Oracle-Jet application, in which I have a requirement to use ojet-lists. I call the data dynamically from a REST API. Here's the Screenshot of the list-view- SS of list

As you can see, I have some values i.e. Sub-Category, Views, and Change%. The problem is I am only able to hide the div for the first element i.e. Consultancy. Here's the JS Code in which I call the REST API and the conditions to hide the divs.

function practiceData() {
        $.getJSON("REST API").then(function (dataset) {

          $.each(dataset, function (index, value) {
            data5.push(value); // PUSH THE VALUES INSIDE THE ARRAY.
            arrow.push(value.change);
            console.dir("data",data5)
          console.log("value",value.change)
          console.log("arrow", arrow);
          arrow.forEach(function(value)
          {
              if (value == 0) {
                document.getElementById("triangle-up-small").style.display = 'none';
                document.getElementById("triangle-down-small").style.display = 'none';
                console.log("rgjak");
                console.log(value);
              } else if (value < 0) {

              //  $("#triangle-up-small").hide();
                console.log("hcdsb");
                console.log(value);
                document.getElementById("triangle-up-small").style.display = 'none';

              }
              else{
                // $("#triangle-down-small").hide();
               $("#triangle-up-small").hide();
                console.log("123");
                console.log(value);
              }
            });
          });
        });

    }

All the array values are Numbers and here's the HTML code for the lists-

<oj-list-view id="listview" aria-label="simple list" data="[[dataProvider5]]">
              <template slot="itemTemplate" data-oj-as="item">
                 <!-- <span class="avatar" data-bind="style: { backgroundImage: 'url(\'../images/dvt/' + item.data.id + '.png\')' }"></span>-->

                  <div class="oj-flex ">
                <div class="oj-sm-5 oj-flex-item"><span class="name"><a id="yo"><oj-bind-text value="[[item.data.subcategory]]"></oj-bind-text></a></span></div>
                <div class="oj-sm-1 oj-flex-item"><span class="oj-text-xs oj-text-secondary-color" style="float: right;"  ><oj-bind-text value="[[item.data.count]]"></oj-bind-text>views</span></div>
                 <div class="oj-sm-1 oj-flex-item" ><div id="triangle-up-small"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                 <div class="oj-sm-1 oj-flex-item"><div id="vl"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                 <div class="oj-sm-1 oj-flex-item"><div id="triangle-down-small"style="float: right;"><span  id="text-red" style="margin-left: 10px;margin-top:0px;"  ><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
              </div>
              </template>
          </oj-list-view>

I have tried every method , any help is appreciated. Thanks for your help in advance.


Solution

  • As, mentioned by @Sumedh Chakravorty, here's the working code for the question.

    <oj-list-view id="listview" aria-label="simple list" data="[[dataProvider5]]">
                  <template slot="itemTemplate" data-oj-as="item">
                     <!-- <span class="avatar" data-bind="style: { backgroundImage: 'url(\'../images/dvt/' + item.data.id + '.png\')' }"></span>-->
                     <script>
    
                       </script>
                      <div class="oj-flex ">
                    <div class="oj-sm-5 oj-flex-item"><span class="name"><a id="yo"><oj-bind-text value="[[item.data.subcategory]]"></oj-bind-text></a></span></div>
                    <div class="oj-sm-1 oj-flex-item"><span class="oj-text-xs oj-text-secondary-color" style="float: right;"  ><oj-bind-text value="[[item.data.count]]"></oj-bind-text>views</span></div>
                    <oj-bind-if test="[[item.data.change == '0']]">
                     <div class="oj-sm-1 oj-flex-item"><div id="vl"style="float: right;"><span  id="text-green"><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                   </oj-bind-if>
                     <oj-bind-if test="[[item.data.change < '0']]">
                   <div class="oj-sm-1 oj-flex-item"><div id="triangle-down-small"style="float: right;"><span  id="text-red" style="margin-left: 10px;margin-top:0px;"  ><oj-bind-text value="[[item.data.change]]"></oj-bind-text>%</span></div></div>
                 </oj-bind-if>
                  </div>
                  </template>
              </oj-list-view>