Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Multipage Mashup - keep selections between html pages?

Hi!

We have received a nice mashup that contains of multiple .html-Pages. See here: http://demo.heldendaten.net:8080/extensions/Vertriebsdemo_Sense_Mashup/Produkte.html

Unfortunately, if a user does selections on one .html-Page (for example Produkt.html), these selections are lost when the user changes to another html page.

From what I see in the .js code, the Mashup always calls the following  code on every new page. See below.

--> to me it seems that calling openApp on every page, opens a new connection to the document --> old selections are lost.

--> I have read through the mashup API, but haven't really found anything to keep the app-session alive between multiple pages. I have played wit the "identity" property of the app config, but no success (running Qlik Sense 2.0.3)

--> has anyone a short example how I can fix the existing code?

var config = {
     host: window.location.hostname,
     prefix: "/",
     port: window.location.port,
     isSecure: window.location.protocol === "https:"
  //,
  //identity: "12349876"
};
require.config( {
     baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port: "") + config.prefix + "resources"
} );

require( ["js/qlik"], function ( qlik ) {
     qlik.setOnError( function ( error ) {
          alert( error.message );
     } );

     //callbacks -- inserted here --
  
     //open apps -- inserted here --
  
  
      app = qlik.openApp("871f98c2-38cd-46b1-9676-6dd3e87f06be", config);

     
  
     //get objects -- inserted here --
  
       $(".qvobject").each(function() {
          var qvid = $(this).data("qvid");
          app.getObject(this, qvid);
     });

29 Replies
Not applicable
Author

Thanks Aiham, then this is the way to go

Anonymous
Not applicable
Author

Hi Roland, have you solved this problem or found a walk-around?

I meet the same problem now. Selection can not be kept among different mashup pages.

I notice if I keep Qlik sense dev-hub open, the selection could be kept among different mashup pages.

I also notice if I open all the mashup pages, the selection could be kept among different mashup pages.

However, is there a technical solution to keep selection among different mashup pages?

Any suggestion is appreciated!

Anonymous
Not applicable
Author

Hi Aiham, I met the same problem in this thread.

I created multi pages mashup at Qlik sense server.

However, there are two big problems.

1): selection can NOT be kept among different mashup pages.

2): selections made by user A will affect the selection of user B. Actually user B will see the same what user A is selecting/doing on the mashup page.

Could you also please give any suggestion about how to create different sessions?

Any suggestion is appreciated!

Anonymous
Not applicable
Author

Hi Aiham, I have created a bookmark in the Javascript file of Qlik sense mashup with the following:

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

app.bookmark.create('CurrentSelections','CurrentSelections');

However, selection still can not be kept during different mashup pages.

Any suggestion is appreciated!

Aiham_Azmeh
Employee
Employee

Hi Haikuo,

1) Selections are part of the current user session so each time the websockets is closed or re-created, you will get a new session; there are a couple of "workarounds" for you problem described here: Re: QS mashups and preserving selections

2) to isolate selections, you should be able to use "identity", see documentation here: openApp method ‒ Qlik Sense

I hope this helps,

regards

Anonymous
Not applicable
Author

Hi Roland,

I met the same problem as the following:

2): selections made by user A will affect the selection of user B. Actually user B will see the same what user A is selecting/doing on the mashup page.

How did you set the 'identity' at

var config = {

    host: "myhost.com",

    prefix: "/",

    port: window.location.port,

    isSecure: true

};

in your Vertriebsdemo_Sense_Mashup.js file.

Thanks so much for your suggestion and help!

Anonymous
Not applicable
Author

Hi Aiham ,

We created a Qlik sense mashup with Qlik sense desktop 3.0, and published it Qlik server 3.0.

The mashup will be public available. All users could Anonymous Login.

How to set in Qlik server, so the selection of User_A on mashup will NOT impact the selection of User_B on the same mashup page at the same page?

Thanks so much for your help!

Anonymous
Not applicable
Author

Hi Steven, I get some suggestion from Qlik. To save the cookie is the best method to keep selection among mashup pages.

My walk-around is to put multi page mashup into one HTML. However, it seems the page loading becomes slow.

moritzreinhard2
Partner - Contributor III
Partner - Contributor III

Just have a look at

https://smartbuilder.novofactum.de/

On this web portal you can build your own multipage Qlik Sense mashups with drag and drop. So you don‘ t need any knowledge in web programming to get an awesome mashup. Simply export your build mashup into a zip file and import it to Qlik Sense. It is for free and you can adjust the code afterwards as well. You only have to register to login.

Selections are kept if you go to another page.

Screenshot.png

ffreitas
Contributor
Contributor

Hi all,

I think I can solve this problem using only Javascript.

The fisrt thing You must know is, my solution need CurrentSelections, I get the information from CurrentSelections, if you don't want to show CurrentSelections, hide him with CSS tag style="display: none".

The first step is create Javascript function, like:

function getSelections(){
require(["js/qlik"], function(qlik) {

var selectionname = document.getElementById("CurrentSelections").querySelectorAll("[tid='selection-name']");
var selectionitemtext = document.getElementById("CurrentSelections").querySelectorAll("[tid='current-selection-item-text']");
var storedNames = [];
var storedValues = [];

for (var i=0; i < selectionname.length; i++){
storedNames[i] = selectionname[i].innerText;
storedValues[i] = selectionitemtext[i].innerText;
}

localStorage.setItem("selectionname",JSON.stringify(storedNames));
localStorage.setItem("selectionitemtext",JSON.stringify(storedValues));

});
}

This function get the name and values of the selections from the CurrentSelections and save this information in webstorage, all modern navigators support webstorage.

The next step is create a hypercube to save all selections in webstorage, this hypercube need to stay in your main page/JS:

//create cubes and lists -- inserted here --
app.createCube({
"qInitialDataFetch": [
{
qTop: 0,
qLeft: 0,
qHeight: 10000,
qWidth: 1
}
],
"qDimensions": [
{qDef: {qFieldDefs: ["oneOfYourIdApp"]}}
]},
function (reply) {
bool = reply.qHyperCube.qDataPages;
if(bool.length > 0) {
// pegando os filtros
getSelections();
}
}
);

Ever time you make a new selection, this information will be saved in webstorage.

Now, in your new page (javascript target page), you need to recreate the selections with the values saved in webstorage:

if (app) {
var storedNames = JSON.parse(localStorage.getItem("selectionname"));
var storedValues = JSON.parse(localStorage.getItem("selectionitemtext"));

for (var i=0; i < storedNames.length; i++){
app.field(storedNames[i]).selectMatch(storedValues[i], true);
}
}

Its done!

This solution uses webstorage so the selections will persist even after the browser is closed, to undo the selections you will need to manually clear them in currentselections or by clearing the browser cache.
If you want to avoid this behavior, replace localStorage for sessionStorage, with sessionStorage the information saved will be lost after tab/window is closed (I don't test this last).

This worked for me, hope it works for someone else.