Dmitry Gudkov's blog about Business Intelligence and Data Visualization

September 1, 2011

Building extensions in QlikView: some hints & tips

Here are some useful hints & tips that I learned while working over Explainum Feeds -- our extension for creating context-dependent comments in QlikView applications.

First of all, I would like to thank Stephen Redmond for his very useful Beginners Guide to QlikView Extension Objects (part 1, part 2, part 3, part 4) -- a mustread for everyone who starts developing extensions.

If you have done with that guide then these hints might be useful for you as well:

Namings

Debugging the extension

Getting custom properties

Accessing other objects

Using external CSS stylesheets

Namings
Make sure that names of extension folders in Windows and corresponding names in extension files like definition.xml, script.js are in the same case. QlikView is sensitive to this.

Getting custom properties
This is one of the earliest tasks when developing custom extension -- how to get custom parameters from the extension properties.

As you know from Stephen's guide there are 2 major components of an extension: definition.xml and script.js. Besides these two there is 3rd important file that we will need as well: properties.qvpp which is located in the extension folder also.

Accessing other objects
This is one of the trickiest things in extensions which may cause some confusion. When dealing with other objects (like listboxes, textboxes, charts and other extensions) it is important to understand that all objects in QlikView WebMode are created in asynchronous mode. This means that one object can exist in point of time when other objects still are not created. Therefore, to access other objects you should use callback functions. Callback functions can be assigned to objects using qva.GetQvObject function. Here is an example of modified extCallback function:
var listboxCallback = function () {
var caption = this.Layout.Caption.label;
alert(caption);
}
var extCallback = function () {
qva.GetQvOvbject("LB01", listboxCallback);
}

There is one more way to access object properties using QvaPublic method. But you have to be sure that accessed object is constructed and valid which is not always true as qva.GetQvObject always returns at least blank object with some basic properties.
var lb_obj;

Here LB01 is object ID which can be seen in General tab of object properties window in QlikView. Remember to assign callback function to an object only once as every call of qva.GetQvObject doesn't replace callback function but adds a new one.

Using qva.GetQvObject you can also access objects from other sheets of a QV application as well, but keep in mind that they have to be constructed and valid prior to accessing them.

Using CSS stylesheets
One day you would want your extension look nicer. It is not so convenient to define complex styles right in HTML, as they can be very lengthy. Much better way is to use external CSS stylesheets, which can be inserted into browser DOM from within extension. Create styles.css in the extension folder and then use it as in the following example:
var cssref = document.createElement("link");
cssref.setAttribute("rel", "stylesheet");
cssref.setAttribute("type", "text/css");
cssref.setAttribute("href", qva.Remote + "?public=only&name=Extensions/MyExtension/styles.css");
document.getElementsByTagName("head")[0].appendChild(cssref);