Qlik Community

Ask a Question

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
rpapa
Contributor
Contributor

Qlik Sense Mash Up - Bookmarks & Table Column Selection

I am developing a qlik sense mashup that essentially loads a hypercube containing the required data and loads it into a jQuery DataTable. I currently have selections and bookmarks integrated into the mashup via the APIs, however I'd like some added features that qlik does not necessarily provide. Ideally:

- When a user begins applying selections, the data filters on the table and only displays relevant rows. This currently works fine and is handled completely by Qlik's engine and HyperCubes, my added code is minimal.

- When the user saves a bookmark and then loads that bookmark, only the data that is relevant should be displayed on the table. Again, this currently works fine and didn't require much code. 

-The problem arises here: I have enabled column hiding/showing on my Datatable to allow users to decide which columns they would like to see. I want users to be able to apply selections, hide whatever columns they'd like, and when the save a bookmark to be able to keep track of what columns are selected, so when the bookmark is again loaded, the table contains only the relevant data AND columns. 

I have tried implementing several methods to combat this issue, including the use of Qlik variables to store the column headers that were selected, and another method which dynamically creates a hypercube based off the visible columns/ selected data, but each method has significant limitations that are ultimately unacceptable for my use case. 

 

Has anyone had such a requirement and successfully implemented a solution? If so, any guidance would be greatly appreciated. 

1 Solution

Accepted Solutions
oz_moyal
Creator
Creator

Hi @rpapa 

if u look here:
https://help.qlik.com/en-US/sense-developer/June2019/Subsystems/APIs/Content/Sense_ClientAPIs/Capabi...

one of the properties when u create variable is: qIncludeInBookmark
maybe it has default of true, it dosen't say in the doc, anyway, better set it to true

As for all the api calls, i'm not in front of my code
but u should check the variable only after you apply bookmark, 
the "app.bookmark.apply" returns a promise, so when the promise resolved, check the variable value, so u will update only after bookmark apply action.

in addition us should u can also save the previous state of this variable, and update the table only if the value has changed.

Since in my case it worked, i think this issues can be solved, if u still have issues try to log exactly when and what happens so i can further help.

View solution in original post

12 Replies
bmd
Employee
Employee

You have two distinct things you're trying to save, selections and column definitions. Selections and Qlik Sense bookmarks are values applied in the application selection state. Column definitions are values applied to a hypercube definition.

What your description below describes is a need to store a selection state with a reference to a particular table definition.

The solution to this that I have seen is to use an external data store, like MongoDB, to save the metadata necessary to recreate the view state.

 

rpapa
Contributor
Contributor
Author

Is it feasible to connect to an external DB, like MongoDB, from within the web portal development hub?

 

I'm currently trying to save the metadata within Qlik Varaibles which has proven to be a bit unstable, I believe due to the auto refresh that comes with every API call made from the 'app' variable. (GetHyperCube, GetBookMark, etc..) 

 

oz_moyal
Creator
Creator

I actually did something similar where I had info that is not stored into the bookmark by default - like which columns to show in a table.

What i did is to create a variable, u need also to make sure u set the property of the variable to save in bookmark 

then when user loads bookmark , i read this variable and apply it to the view. 
Why this  approach didn't work for u ? 

bmd
Employee
Employee

The ability to connect to something like MongoDB would be determined by the network topology where Qlik Sense is installed.

Although, looking deeper into @oz_moyal's strategy may be a better track for your requirements.

rpapa
Contributor
Contributor
Author

This is essentially what I'm doing. It 'works' in the sense that the column metadata is properly saved, but the amount of api calls and auto-reloades causes the table to occasionally display incorrect columns/unexplained behavior. 

 

'u need also to make sure u set the property of the variable to save in bookmark'

Can you elaborate on this? What do you mean by set the property of the variable to save in bookmark?

I am using app.variable.create(name, description) then app.variable.setStringValue([column headers]). Is there  an extra step that I need to take to make the bookmark aware of it? 

 

@oz_moyal 

oz_moyal
Creator
Creator

Hi @rpapa 

if u look here:
https://help.qlik.com/en-US/sense-developer/June2019/Subsystems/APIs/Content/Sense_ClientAPIs/Capabi...

one of the properties when u create variable is: qIncludeInBookmark
maybe it has default of true, it dosen't say in the doc, anyway, better set it to true

As for all the api calls, i'm not in front of my code
but u should check the variable only after you apply bookmark, 
the "app.bookmark.apply" returns a promise, so when the promise resolved, check the variable value, so u will update only after bookmark apply action.

in addition us should u can also save the previous state of this variable, and update the table only if the value has changed.

Since in my case it worked, i think this issues can be solved, if u still have issues try to log exactly when and what happens so i can further help.

View solution in original post

rpapa
Contributor
Contributor
Author

Thanks so much. This seems like a viable solution, so I will mark this as resolved. I will try to implement this in the near future, and given the possibility that it does not solve the problem I will re-open. Thanks so much for all the responses!
oz_moyal
Creator
Creator

You are welcome @rpapa 
Please feel free to ask on any issue, will do my best to help, as i did something similar

rpapa
Contributor
Contributor
Author

@oz_moyal 

Trying to implement.... running into a few issues. 

Is it possible to extract the qDefinition that a variable is given? I see the possible .get methods on https://help.qlik.com/en-US/sense-developer/June2019/Subsystems/APIs/Content/Sense_ClientAPIs/Capabi... but they don't seem to do what I need. I know I can use .setStringValue and .getStringValue to pass my table headers to the variable... but this results in further api calls that I'd prefer not to execute. 

EDIT: I know the .get method returns a promise that contains some information about the variable, but I do not see any field such as .qDefinition. This is what I am looking for if possible.