Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I'm trying to get the list of sheets from within the "paint" function. The following code is with the paint function:
define([
"qlik",
"jquery",
'underscore',
], function(qlik,$,_) {
'use strict';
var me = {
initialProperties : {
....
....
};
me.app = qlik.currApp(this);
me.paint = function($element, layout) {
var sheets = [];
...
...
...
me.app.getAppObjectList( 'sheet', function(reply){
var title = "", loc_nb_navlist = "", loc_sheets = [];
var sortedData = _.sortBy( reply.qAppObjectList.qItems, function ( item ) {
return item.qData.rank;
} );
_.each( sortedData, function ( item ) {
sheets.push( {
id: item.qInfo.qId,
name: item.qMeta.title
} );
console.log ('sheets array inside: '+sheets);
qlik.Promise.resolve (sheets);
} );
}).then(function () {console.log('done get sheets')});
console.log ('sheets array outside: '+sheets);
...
...
});
return me;
});
The console.log for the sheets array inside the call shows the objects fine, but outside the object is empty. The sheets array are populated inside the call, but become empty outside, so i can't use it. Any help is appreciated.
Thanks
Elias
Hi Elias,
Do not use the getAppObjectList method in paint. If you instead add appObjectListDef to your properties the framework will handle the asynchronity for you and your paint method will be called when the data is available.
Hope this helps
Erik Wetterberg
Hi Erik.
Thanks for the reply. Do you have an example of adding appObjectListDef to the properties?
Thanks
Elias