3 Replies Latest reply: Jun 26, 2018 4:29 AM by Erik Wetterberg RSS

    Hypercube misses out last column when adding a new dimension or measure

    Jake Yallop

      I'm creating a Qlik Sense table extension using Angular.

       

      I have a requestData function that runs whenever a new column is added to the table. The width + 2, is temporary so that I can be sure that qWidth is not too small. The value is correct without the +2 included.

       

      function requestData(height, top, app, hc, headingsMap, callback) {
      if (DEBUGMAXROWCOUNT <= rowCount) {
      console.warn("DEBUG: Max rowcount reached");
      } else {
           console.log(hc);
           var newWidth = compareColumns(headingsMap, hc);
           if (newWidth || top < hc.qSize.qcy) {
                var requestPage = [{
                     qTop: top,
                     qLeft: 0,
                     qWidth: newWidth + 2, 
                     qHeight: height
                   }];
                console.log("requesting new data...")
                rowCount += height;
                app.getData(requestPage).then(function (dataPages) {
                     console.log("Finished requesting data.");
                     if (callback) {
                          callback();
                     }
                 });
                }
           }
      }
      

       

      When the page is initially loaded, all the data is populated correctly. Removing a column also still results in the correct data.

       

      The function, ran normally like this when a new column is added:

      requestData(computeMaxRowCount($scope.headingsMap.length, hypercube.qSize.qcy - rowCount, 10000), rowCount, $scope.backendApi, hypercube, $scope.headingsMap, function () {
      console.log("hypercube", $scope.layout.qHyperCube);
      });
      

       

      Misses out the last column that was added. Logging the hypercube before the app.GetData call, shows the hypercube has the correct number of dimensions/measures. Looking at it afterwards, it has the correct dimensions and measures.

       

      Running the function with a delay fixes the issue, but it seems like very odd, and inconsistent behavior, especially when everything else seems correct.

      setTimeout(function(){
           requestData(computeMaxRowCount($scope.headingsMap.length, hypercube.qSize.qcy - rowCount, 10000), rowCount, $scope.backendApi, hypercube, $scope.headingsMap, function () {
                console.log("hypercube", $scope.layout.qHyperCube);
           })
      }, 50);
      

       

      Is there a way to fix this without needing the setTimeout?