3 Replies Latest reply: Jun 27, 2018 3:22 AM by Casper van Pomeren RSS

    Re-opening an object after closing it

    Casper van Pomeren

      Hello everyone,

       

      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):

      $("a[href$='#page1']").click(function(){

      app.getObject('QV01','WJYuPN');

      app.getObject('QV02','JcJvj');

      app.getObject('QV03','qamd');

      app.getObject('QV04','nPLRub');

       

       

       

      app.getObject('QV05','bsxkrg').then(function(model) {

            model.close();

      });

      app.getObject('QV06','vCNaSe').then(function(model) {

            model.close();

      });

      app.getObject('QV07','RfEbJ').then(function(model) {

            model.close();

      });

      app.getObject('QV08','MRmuW').then(function(model) {

            model.close();

      });

      });

       

      $("a[href$='#page2']").click(function(){

      app.getObject('QV05','bsxkrg');

      app.getObject('QV06','vCNaSe');

      app.getObject('QV07','RfEbJ');

      app.getObject('QV08','MRmuW');

       

      app.getObject('QV01','WJYuPN').then(function(model) {

            model.close();

      });

      app.getObject('QV02','JcJvj').then(function(model) {

            model.close();

      });

      app.getObject('QV03','qamd').then(function(model) {

            model.close();

      });

      app.getObject('QV04','nPLRub').then(function(model) {

            model.close();

      });

      });


      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 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)

          at qlik.js:37


      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.

       

      Thanks in advance,

       

      Casper

        • Re: Re-opening an object after closing it
          Casper van Pomeren

          I am also happy with ideas instead of solutions . I have tried everything I could think of, so if any smart people here have some new ideas, please let me know.

            • Re: Re-opening an object after closing it
              Erik Wetterberg

              Hi

              You could try the visualization API instead. You do something like this:

              app.visualization.get('WJYuPN').then(function(vis){

                vis.show('QV01');

              });

               

              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

                • Re: Re-opening an object after closing it
                  Casper van Pomeren

                  Hi Erik,

                   

                  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.

                   

                  Casper