3 Replies Latest reply: Sep 19, 2017 4:24 PM by Bruno Cavestro RSS

    'SetOnUpdateComplete' called multiple times

    Stefan Stoichev

      Hi all,

       

      im building QV object extension but it have very strange behaviour. Im in the beggining of the development process and so far the extension itself is very simple

      • get the current document
      • get 'LB03' object
      • wait until the object is finished
      • get the object values
      • display this values in the extension and color them based on their state

       

      The problem is that for some reason when i select values anywhere on the document `SetOnUpdateComplete` function is being called multiple times (usually 3 times) and this makes my object to be re-drawn multiple times as well which leads to some "flickering" - at one moment i can see the old values (with the selection state before the selection), then i can see all values (old and new) and finally i can see the new values

       

      Any idea why this is happening?

       

       

              var finalHTML = ''

       

              var doc = Qv.GetCurrentDocument();

              var lb = doc.GetObject("LB03");


              $('#' + divName).html('');

              lb.SetOnUpdateComplete(function (d) {

                  console.log(1)

                  $('#' + divName).html('');

                  for (var i = 0; i < lb.Data.Rows.length; i++) {

                      $('#' + divName).html('');

                      var dataRow = lb.Data.Rows[i][0]


                      var style = '';


                      if (dataRow.state == 'Selected') {

                          style = ' background-color: green ';

                      } else {

                          style = ' background-color: gray ';

                      }


                      finalHTML += '<div style="' + style + '">' + dataRow.text + '</div>'

                  }


                 $('#' + divName).html(finalHTML);

              })

       

       

       

      Regards!

      Stefan