Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
BradMazurek
Contributor II
Contributor II

Selections not populated after reload?

(Edited to add code and images.)

In my extension's paint() method, I am accessing the selectionState().selections array. All seems to work fine generally, but when I do a reload of the webpage, the selections array is empty when paint() is called. A subsequent interaction that causes paint() to be called again finds the selections array populated.

Have I got some sort of race condition where the app has yet to load/cache the current selections?

Here is some sample code:

define(["qlik","css!./styles.css"], function (qlik) {

	return {
		support : {
			snapshot: false,
			export: false,
			exportData : false
		},
		paint: function ($element) {
			console.log(qlik.currApp().selectionState());
			console.log(qlik.currApp().selectionState().selections);

			return qlik.Promise.resolve();
		}
	};
} );

And here are images demonstrating my issue:

1. I currently have three Fields (4 Field Values) selected.

Annotation 2019-12-27 081422.png

 

 

 

 

2. When I reload my JS console shows the following. Note the highlighted parts.

Annotation 2019-12-27 081423.png

3. When I then open those interactively in the console, they are populated.

Annotation 2019-12-27 081424.png

Thus, at the time paint() is called, my extension does not have the correct information about what is selected.

Labels (2)
2 Replies
Harsh_Gohil
Partner - Contributor III
Partner - Contributor III

hello,

can you please provide demo of your code?

Regards,

Harsh Gohil

BradMazurek
Contributor II
Contributor II
Author

I think I figured it out.

The selections may not yet be loaded, so I should bind a listener to 

qlik.currApp().selectionState().OnData

I would suggest the documentation be updated to indicate a few things:

  1. The content of qlik.app.selectionState() is indeterminate until after an OnData event is received any associated listeners.
  2. Some indication of under what circumstances the OnData event is triggered. (Obviously during a selection, but also during page load. Are there more cases?)