Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Announcements
Qlik® Product Spotlight: Discover what’s possible. Get more from our products.
See for yourself. Register today.
kmcgovern1
Contributor

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
Employee
Employee

Re: List of Sheets in Extension Properties

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

kmcgovern1
Contributor

Re: List of Sheets in Extension Properties

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

Re: List of Sheets in Extension Properties

kmcgovern1
Contributor

Re: List of Sheets in Extension Properties

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!