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.
cjmckenna
New Contributor

Dynamically create multiple qListObjectDef objects with array property

Hello all,

I am just getting started creating qlik sense extensions, and I'm having a bit of trouble. I see that you can define multiple qListObjectDefs in the initialProperties section of an extension. But I am looking for a way to create a qListObjectDef for each Dimensions added in the properties panel using an array property. I have 2 main questions:

  1. How can I create qLIstObjectDef objects when a user adds a new item to an "array" property?
  2. How do i then assign the values from this array to a qListObjectDef

My current code looks like this:

initialProperties: {

version: 1.0,

                qListObjectDef: {

                    qShowAlternatives: true,

                    qFrequencyMode: "V",

                    qSortCriterias: {

                        qSortByState: 1

                    },

                    qInitialDataFetch: [{

                        qWidth: 1,

                        qHeight: 10000

                    }]

                },

myArray: []

},

definition: {

type: "items",

component: "accordion",

min: 1,

max: 1,

items: {

dimension: {

type:"array",

label:"Dimensions",

ref: "myArray",

itemTitleRef:"arrayLabel",

allowAdd: true,

                        allowRemove: true,

                        addTranslation: "Add Dimension",

items: {

label: {

type:"string",

ref:"arrayLabel",

label:"Label",

show: true

},

                            field: {

                                type: "string",

                                expression: "always",

                                expressionType: "dimension",

                                ref: "arrayField",

                                label: "Field",

                                show: true

                            },

style: {

ref: "vars.filterType",

expression: "optional",

translation: "Filter Type:",

type: "string",

defaultValue: "Checkbox",

component: "dropdown",

options: [{

value: "Checkbox",

label: "Checkbox"

},

{

value: "Radio",

label: "Radio"

}]

                            }

}

},

appearance: {

uses: "settings"

}

}

},

I am trying to create a functionality similar to the built in filter pane, that allows a user to define multiple dimensions in a single extension to use for filtering.

Thanks,

Colin

3 Replies
Employee
Employee

Re: Dynamically create multiple qListObjectDef objects with array property

If you want a dynamic set of list objects, then you should probably put the list object definitions in an array as well. They don't have to be on a top level. The only important thing is that they are defined in properties with the label "qListObjectDef". In other words, you could write like this:

initialPoperties: {

version: 1.0,

listObjects: [

  { qListObjectDef: { <definition of list object 1>},

  { qListObjectDef: { <definition of list object 2>},

  ...

]

Does this answer your question?

The Map-visualization utilizes something similar to this. It has an array of layers that contain hypercubes and/or list objects. And by the way, if you want a simple way of inspecting the properties (and layouts) of objects in Qlik Sense, then I can recommend this tool: Qlik Explorer for Developers is here!)

And a last note: The native Qlik Sense filter pane does actually not use this technique. Instead, that object has a number of children (one for each dimension) where each of the children contains it's own qListObjectDef.

cjmckenna
New Contributor

Re: Dynamically create multiple qListObjectDef objects with array property

Thanks for the response!

This is helpful, but my issue is that I won't know exactly how many qListObjectDefs i'll need to define on initialization, but instead will need to create one each time a dimension is added. Can you define these qListObjectDefs outside of the initialProperties declaration?

Also you mentioned this is not how the native Qlik Sense filter works. Is the source code for that available anywhere? I would be curious to see how it works.

Thanks,

Colin

Employee
Employee

Re: Dynamically create multiple qListObjectDef objects with array property

You can always change the properties by using this method: SetProperties method ‒ Qlik Sense

Which API are you using? Based on your initial posting I would assume you are using javascript? In that case you might want to look at this page: setProperties method ‒ Qlik Sense

If you are new to the engine API, then it could also be a good idea to have a look at these pages:

The source code for the Qlik Sense filter pane is not publicly available, but it uses the CreateChild method to add a new list object every time you add a new field.