Typically, the most common properties used by any Qlik Sense visualization are Dimensions, Measures, and Appearance. The appearance section is included by default when we create any Qlik Sense visualization, even if the Properties panel is not defined.
We can extend the definition of these properties in the JavaScript code to reuse the built in sections. The following recipe demonstrates how to define and extend the definitions of properties in Qlik Sense visualization and further reference these properties in our code.
This recipe is a continuation of the previous recipe. So, we will be using the same QlikSense-Cookbook-C7-R1-HelloWorld.js
file, which contains the code for the dynamic extension as discussed in the There's more... section.
QlikSense-Cookbook-C7-R1-HelloWorld.js
file located at C:Users<username>DocumentsQlikSenseExtensions QlikSense Cookbook – Hello World
.QSpropertyPanel
under items
:sorting: { uses: "sorting" }
paint
function:console.info('paint >> layout >> ', layout); $element.empty(); var $helloWorld = $(document.createElement('div')); // Variable holding the output var html = '<b>Property values:</b><br/>'; html += 'Title: ' + layout.title + '<br/>'; html += 'SubTitle: ' + layout.subtitle + '<br/>'; // Assigning the variable to our output container $helloWorld.html( html ); //$helloWorld.html(layout.QSDynamicExtension); $element.append($helloWorld);
QlikSense-Cookbook-C7-R1-HelloWorld.js
file will look like the following code:define( [ 'jquery' ], function ( $ ) { 'use strict'; return { definition: { type: "items", component: "accordion", items: { appearancePanel: { uses: "settings", items: { QSPropertyPanel: { ref: "QSDynamicExtension", type: "string", label: "QlikSense extension Text" }, sorting: { uses: "sorting" } } } } }, paint: function ( $element, layout ) { //console.log(layout); console.info('paint >> layout >> ', layout); $element.empty(); var $helloWorld = $(document.createElement('div')); // Variable holding the output var html = '<b>Property values:</b><br/>'; html += 'Title: ' + layout.title + '<br/>'; html += 'SubTitle: ' + layout.subtitle + '<br/>'; // Assigning the variable to our output //container $helloWorld.html( html ); $element.append($helloWorld); } }; } );
Qlik Sense CookBook-Hello World
and SubTitle as Chapter 7
.We reference the defined properties in our JavaScript file under the paint
section. We use a layout
parameter that includes the current scope of the visualization extension together with the properties; this
parameter is passed to the paint
method.
We can use other native Qlik Sense properties in our Properties panel definitions such as Dimension, Measure, Data Handling, Reference lines, and so on. For more information on the Add-Ons go to the following address: