Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

List of Sheets in Extension Properties

Hi all,

For my extension I am using the qlik.currApp().getAppObjectList( 'sheet',callback) method to get a list of all the sheets in a document and update the DOM.  However, I want to also include a list of all sheets in the document in my properties.  Because getAppObjectList only accepts a callback for the sheet list I can't update my properties synchronously.  Is there an alternate method to retrieve the list of sheets via another method that allows me to get the list synchronously?  Alternatively, is there a way to update the extension properties asynchronously?

define(['qlik'], function (qlik) {

    //create var that contains api method of current object

    var apiMethod = qlik.currApp();

    //declare value var to be used inside callback

    var sheetPropVar ='';

    //call getAppObjectList, specifying an argument and use callback to access contents of method

    apiMethod.getAppObjectList('sheet',function (reply) {

        //loop through each value inside callback

        $.each(reply.qAppObjectList.qItems, function (key, value) {

            //add values to variable for each instance of method

            sheetPropVar += 'the key is '+key+' and the value is'+value;

        });

    });

    //return some values as well as the value set above for the overall define method

    return {

        type: "items",

        component: "accordion",

        items: {

            appearance: {

                uses: "settings"

            },

            configuration : {

                    component: "expandable-items",

                    label: "Sheet Configuration",

                    items: sheetPropVar //sheetPropVar is '' since it is set insde a callback function

            }

        }

    }

});

Thank you in advance for your help.

Side note: I am not using Angular for my extension right now.

4 Replies
Stefan_Walther
Employee
Employee

Hi,

have a look here, where you can find some code ready for copy & paste:

https://github.com/stefanwalther/sense-navigation/blob/master/src/properties.js

Hope this helps.

Regards

Stefan

Anonymous
Not applicable
Author

Thanks, swr! That was extremely helpful.  I'm almost there but my properties panel is still coming up blank.  What am I doing wrong?

define( ['qlik','ng!$q','underscore'], function (qlik, $q, _) {

    'use strict';

    var app = qlik.currApp();

  var getSheetListFormatted = function () {

  var defer = $q.defer();

  app.getAppObjectList( function ( data ) {

  var sheets = [];

  var sortedData = _.sortBy( data.qAppObjectList.qItems, function ( item ) {

  return item.qData.rank;

  } );

  _.each( sortedData, function ( item ) {

  var sheetTitle = 'sheet'+item.qInfo.qId;

  var innerObj = {

  type: "items",

  label: item.qMeta.title,

  items: {

  enabled: {

  ref : "buttons.isEnabled",

  label : "Show this Sheet",

  type : "boolean",

  defaultValue : true

  }

  }

  };

  var foo = {};

  foo[sheetTitle]=innerObj;

  sheets.push( foo );

  } );

  return defer.resolve( sheets );

  } );

  return defer.promise;

  };

  var altSheetList = {

  component: "expandable-items",

  label: "Sheet Configuration",

  items: function () {

  return getSheetListFormatted().then( function ( items ) {

  return items;

  } );

  }

  };

    return {

        type: "items",

        component: "accordion",

        items: {

            appearance: {

                uses: "settings"

            },

            behavior: altSheetList

        }

    };

});

Not applicable
Author

Anonymous
Not applicable
Author

Hi Navven,

Thanks for your reply.  However, I'm not sure how the doReload method would help me get a list of the sheet names in an application.  Is there a chance you pasted the wrong link?

Thanks!