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

QS mashups and preserving selections

Hi

I have several html pages where I use QS objects from single document. What I want is to preserve/transfer selections which I make on one page to another page. What is the best/correct way to do it? Is it some setting or I need to invoke API. Any samples would be much helpful. Thanks

24 Replies
Not applicable

Hello,

I talked with people at Qlik about this, and they recommanded using a single page (one session) and destroying the model whenever you change "page" (in Angular, for example) or you hide the divs (if you do it yourself). That way, you won't get reduced performances.

We were using iframes and their guess was that we used to many sessions, and that Qlik Server would drop the sessions after a while.

Here is the code to disconnect charts before hidding them. If you have many, you could keep a collection and close the model for each chart.

var modelRef;

  1. app.getObject(<elemId>, <objId>).then(function(model) {

    modelRef = model;}

//then when you want to close it

modelRef.close();





An other possibilities is to create a bookmark before leave the first tab ( or first mashup page), apply this bookmark (it's the last bookmark) when you load the second mashup page and remove this bookmark.


Not applicable

Hi Darius,

We are also planning for Mashup app and want to host our app to server which don't have Qlik Sense install.

Can you please send me some doc/ links where I can get started and code about how to get session ID for a particular user and pass it to QLik Sense server.

Would appreciate you help.

pnowicki
Creator
Creator

I plan on converting to the single page idea.  But this is a workaround.  I was hoping for Qlik to address the root cause and provide a solution to the problem.  You should be able to pass selections from one .html to another without having to perform the div hiding gymnastics of the single page concept. 

For example, in Qlikview you can pass selections in hyperlinks from one Qlikview report to another by modifying the url and adding the selections at the end. 

Alexander_Thor
Employee
Employee

Which you also can in QS

App Integration API ‒ Qlik Sense

pnowicki
Creator
Creator

I don't believe this works with extensions, can you give an example?

I tried something like this:

https://QlikSenseServer/extension1/mashup1/mashup1.html/field1/selection1

brijeshvma
Partner - Creator
Partner - Creator

Hi Aiham

In Our Company as well , We Created Mashup with Multiple Page . To Create a Mashup we used a Single Configurator

IFrame Option. Am facing a Same issue that selection made on one page is not showing on another page . I tried your

given Suggestion on that . and i tried like this Way

<iframe src="https://qap server name/single?appid=cd2908ab-e2ab-4742-ac45-45753bcaf468&sheet=FbXVP&identity=1234&opt=currsel" frameborder="0"></iframe> ----  Page 1

<iframe src="https://qap server name/single?appid=cd2908ab-e2ab-4742-ac45-45753bcaf468&sheet=AnsXty&identity=1234&opt=currsel" frameborder="0"></iframe> ------ Page 2

But its not helping anything. Can you suggest me anything on this?

Aiham_Azmeh
Employee
Employee

Hi Brijesh,

The real issue with multipage-mashup is actually the reloading part => so if you have a mashup (or a Sense sheet) open on in a browser on a single tab, by making selections then reloading the page, you will lose all your selections -- and the reason is obvious: the websocket (communicatinig to the app(s)) is closed and on reload newly created, so you will get a new session thathas nothing to do with the previous one. It's a WAD (Works As Designed), and practically an other software found in the wild works like that.

The solution/workaround:

A - [the recommended one] instead of a multipage-reload mashup, try to build you mashup as a "single page", without reloading your app on navigation - can be done with angular routing, location.# parsing etc...

B - [the hack] on[window]beforeunload create/save a bookmark with the actual selections, which can be applied on the new freshly opened page. AFAIK (I think), this is how it is done in QlikView, but I really do not recommend this approach; it's a hack, and probably not something that you want to have in production.

C - [the real workaround] do not open the new pages in the same tag; use target="_blank" or window.open(URL,'_blank') => this way your websocket connection will still be reusable in that browser, and the user will be able to keep his selections between pages

Conclusions:

In your case I will definitively go for solution C, it will be the easiest to implement

Considerations:

- identity: It feels like the identity parameter is a little bit misunderstood - the purpose of "identity" is to keep the users using the same session in an isolated scope, not altering the shared session - passing selections from session to session will not be solved by it.

- keeping selections between newly created sessions: at R&D we are trying to find a solution for solving this issue, it's under investigation - and I hope that soon we will be able to provide it to you .

regards,

aiham

pnowicki
Creator
Creator

Thibaut,

I've converted to a single page mashup, but did not choose angular, just implemented the div hiding and # target setup. I am now having performance problems since I load all objects all the time.  I'm trying to implement your code example to only have the current objects open when I need them.  I have a .js code that performs actions whenever the page is changed, I can use the trigger in this code to initiate the open/close of the objects.  Is it possible to detect which objects are currently open and close all those before manually getting the new objects for the target page?  Any additional coding examples would be helpful. 

Not applicable

I don't use this method, I keep my multi-pages mashups.  I create a bookmark before leave the first tab, apply this bookmark and remove it.

pnowicki
Creator
Creator

FYI

I've updated my mashup and implemented the modelRef code from above.  I'm not sure if I'm actually destroying the objects as I haven't seen a  noticeable performance improvement.  Here is the code I've implemented.

var tabs = true;

  var flag1 = 0;

  var modelRef;

  var app = qlik.openApp("xxxxxxxxxxxxxx", config);

  app.getObject('CurrentSelections','CurrentSelections');

  if (tabs) {

  $(document).ready(function () {

  $(".view").hide();

      $(window).on("hashchange", function() {

       //destoy

       destroyQlikObjects(flag1)

       var hash = window.location.hash;

       if (hash === "") {

             window.location.hash = $("ul.nav li:first-child").children().attr("href");

         }

         $("ul.nav li").removeClass("active");

         $("ul.nav li").find('a[href="' + hash + '"]').parent().addClass("active");

         $(".view").hide();

         $(hash).show();

         qlik.resize();

       $(window).scrollTop(0);

       updateBreadcrumbs(hash);

       updateQlikObjects(hash);

         });

         $(window).trigger('hashchange');

     });

    }

   function updateQlikObjects(hash) {

   if (hash == "#EBBIT") {

  flag1 = 1;

//EBBIT Summary Objects

  app.getObject('QV1-1','HduqPNJ').then(function(model){modelRef = model;}); //Change Date

  app.getObject('QV1-2','BaPBR').then(function(model){modelRef = model;}); //Report as of:

  app.getObject('QV1-3','typMcue').then(function(model){modelRef = model;}); //KPI box - T Ebbit Global

  app.getObject('QV1-4','FrDerNe').then(function(model){modelRef = model;}); //KPI box - T-1 EBBIT Global

  }

if (hash == "#NetRev") {

  flag1 = 1;

  //Net Rev Objects

  app.getObject('QV2-1','mtTkRbU').then(function(model){modelRef = model;}); //KPI box - T-1 Net Revenue Global

  app.getObject('QV2-2','VepYmCk').then(function(model){modelRef = model;}); //KPI box - MTD Net REvenue Global

  app.getObject('QV2-3','BayF').then(function(model){modelRef = model;}); //KPI box - YTD Net Revenue Global

  app.getObject('QV2-4','fJcQAFu').then(function(model){modelRef = model;}); //Bar Chart - Moving Averages

  }

  }

  function destroyQlikObjects(flag1) {

       if(flag1 == 1) {

            modelRef.close();

       }

  }