Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
niceqlik
Partner - Contributor III
Partner - Contributor III

Using GetQvObject in Extensions

Hi folks,

I have a very basic, simple question :

Can someone tell me where the best place is to define QV objects in an extension javascript file and how?

Consider my extension script.js file looks like below:

// Script.js //

// Place 1

Qva.AddExtension('MyExtension',function() {

// Place 2

});

// Script.js //

I want to define my listbox objects :::

var LBObject;

LBObject = qva.GetQvObject("LB04",function() {});

and call it in ANY place of my code globally? like:

LBObject.QvaPublic.Data.SelectTexts([1,2,3,4]);

But for some reason , i sometimes receive

"LBObject.QvaPublic.Data" null or not an object javascript error when a click event occurs.

I have reviewed most of documentations about extensions but so far i couldnt find no good explanation.

Thanks for your help.

1 Reply
Not applicable

To my experience there is no safe way of using what GetQvObject returns outisde the callback function. Sometime, and for some objects, it works, and other times it doesn't work.

The safest way to access data of a list box object is to put it inside the callback function:

var LBObject;

LBObject = qva.GetQvObject("LB04",function() {

     // safe access to Data here

});

The callback function is activated whenever the object is painted (either because it was changed/moved/resized/etc. or because another GetQvObject for it was activated).

The problem here is that a reference to the callback is kept by QlikView and whenever the object is painted it is called, so bear in mind that the function is not a one time callback, but it should properly handle further activations of itself.

What I do is to handle all situations that this list box can be in in a single callback function and then when I need to activate it manually I intiate a GetQvObject call with an empty callback (qva.GetQvObject("LB04",function() {});).

I know there are exceptions for this. For example I successfully access x.QvaPublic.SetVariable()

on a global variable that holds a reference to an input box (that was populated using a call to GetQvObject).

(This is very awkward and unpleasent way of handling QlikView objects and if there is another way of doing so I would love to hear about it.)