Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

jakeyallop
New Contributor

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

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?

Tags (2)
3 Replies
erik_wetterberg
Honored Contributor

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

Vi,

Looks interesting. Exactly how are columns added and how do you trigger your function? Adding a column in the property panel would trigger a setProperty call which would update the client side model. If you call get data before the modification is ready you might get this result, but there might be another reason. You would probably need to check the browser console and follow the calls on the website. Specifically check the order of setProperties and getHypercubeData calls.

Erik Wetterberg

Erik Wetterberg
https://extendingqlik.upper88.com/
jakeyallop
New Contributor

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

Thanks for the assistance so far. Some answer's to your questions:

The function is triggered whenever data needs to be refreshed.

It will be called when a single column is added, or if a property is changed (as this seems to refresh the data, even if the property doesn't actually change anything about the data itself). The rows defined in IntialDataFetch are fetched correctly, but for any extra rows after that (fetched via the function specified) the cells in the last column are not present.

What's the best way to check the SetProperties/GetHypercubeData calls? Just some adding some breakpoints in the browser?

erik_wetterberg
Honored Contributor

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

Hi,

Best way is probably developer console, network tab and look at the web socket.

Erik Wetterberg

Erik Wetterberg
https://extendingqlik.upper88.com/
Community Browser