I am currently making a one page website that contains a lot of Qlik Sense Objects. The problem with my one page website is that all the objects are present at the same time and they aren't limited to the objects you can see (like in a normal Qlik Sense dashboard). All these objects cause a lot of performance issues because every selection influences all the objects at the same time.
To solve this problem, I have come up with a number of solutions: 1) Only enable the Qlik Sense Objects that the user can see. I was hoping there was maybe an option like noInteraction or noSelections that does include the object, but makes it ignore any other selection for the time being. Unfortunately, an option like this isn't available and as far as I can tell there is no other way to achieve this.
2) Insert and remove the Qlik Sense Objects based on the scroll position. This way wherever the user goes he can see and use the Qlik Sense Objects and at the same time they aren't all calculating in the background (because they get removed if you aren't at the right scroll position). To test if this would work I made a very simple testcase (where I ignore the scroll position for now): - When button A has been pressed -> Load objects 1-4 and remove objects 5-8;
- When button B has been pressed -> Load objects 5-8 and remove objects 1-4;
The code to achieve this (my one page website is split up in multiple pages):
The problem is, when I press button A and then button B (or the other way around), I don't see my objects anymore and I get the following error:
require.js:19 TypeError: Cannot read property 'qType' of undefined
at Object.A.f.setLayout (qlik.js:107)
at a.c [as fn] (qlik.js:107)
at a.<anonymous> (qlik.js:37)
at g (require.js:20)
at o.$eval (require.js:20)
at o.$digest (require.js:20)
at o.$apply (require.js:20)
at Object.$apply (require.js:38)
I think the problem lies in the usage of app.getObject in combination with model.close(). The problem is, I don't know how to solve this issue. I have tried using destroySessionObject , but this method doesn't work (and that's correct I think, because as far as I know destroySessionObject isn't the correct method to use here). I have also looked at the DestroyObject method, but I can't find any examples on how to use it.
To conclude, my question is: how do I successfully re-open my Qlik Sense objects after closing them? If there is a better way to solve my original problem I would also love to hear it.
The visualization you get back has a close() method, which might be what you need. (never mind the code example in the doc, you will find the close() method on the object you get back from app.visualization.get promise.
Another possible solution is to not close objects. I don'ät think the built-in client closes objects, so it might work anyhow.
Erik Wetterberg https://extendingqlik.upper88.com/
Sorry for my late response. I have tried using what you have suggested but I run into the same problem as before (I can't re-open them).
After thinking for a while and based on your answer I think I have found a different solution. Previously the idea was to keep the HTML unchanged and just don't load the qlik object through the JS. The new idea is to not close the object like you suggested and just changing the HTML to include the reference to the qlikobject based on the scrollposition. This way the qlik objects don't all load and don't cause any performance issues.
I am currently working on making it work and when it's done i'll post the solution so other's can use it as well. Thanks for the help.