Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
amitghaste
Contributor II
Contributor II

Selections get reset when switching apps in a mashup

Hi Experts,

I have a simple mashup that I created to test out the selection model, using Angular JS. I have attached my code, along with my sample "apps", pardon the crude code as I am still just trying things out.

What do I want to do?

I want to apply selections between two apps when I switch back and forth between them.

What did I do to make it happen?

when I select a value, I store it in the localStorage, when I switch an app, I retrieve it from the localStorage and use field.selectValues to set the values.

me.qapp.getList("SelectionObject", function(reply) {
					console.log(reply.qSelectionObject.qSelections);
					localStorage.setItem("dashboardSelection", JSON.stringify(reply.qSelectionObject.qSelections))
					//me.store();
				});
promiseArray.push(fld.selectValues( valArray, true, true ));

What actually happens?

when I switch to the second app, the values get selected, but when I switch back to the original app, it gets reset.

From the bind, I can see it getting triggered to set it to empty after the select values are completed.

 

I am using the promises wherever a function returns one, and q.all to wait for. I even introduced app.lockAll and app.unlockAll to act as a trigger mechanism for setting the values.

I even introduced waitForOpen to see if it would help with the timing.

app.model.waitForOpen.promise.then

 

Thank you

AG

Console Log

my-angular-module.js:140 S {fieldCache: {…}, stateCache: {…}, qEvent: t, close: ƒ, id: "1d0e9665-1a42-41ca-bd4c-4552fdff4dc7", …}
my-angular-module.js:143 App {_super: undefined, rpcOptions: {…}, session: d, waitForOpen: u, notification: ƒ, …}
my-angular-module.js:145 apply selections
my-angular-module.js:40 []
my-angular-module.js:72 []
my-angular-module.js:78 []
my-angular-module.js:78 [{…}]


my-angular-module.js:112 n {OnData: n, qapp: S, selections: Array(0), stateName: "$"}
my-angular-module.js:115 []
my-angular-module.js:140 S {fieldCache: {…}, stateCache: {…}, qEvent: t, close: ƒ, id: "1ff9edf1-9815-451f-8ff6-e23a3a21eb11", …}
my-angular-module.js:143 App {_super: undefined, rpcOptions: {…}, session: d, waitForOpen: u, notification: ƒ, …}
my-angular-module.js:145 apply selections
my-angular-module.js:40 [{"qTotal":5,"qField":"COl1","qSelectedCount":1,"qSelected":"A","qRangeInfo":[],"qSortIndex":0,"qStateCounts":{"qLocked":0,"qSelected":1,"qOption":0,"qDeselected":0,"qAlternative":4,"qExcluded":0,"qSelectedExcluded":0,"qLockedExcluded":0},"qSelectedFieldSelectionInfo":[{"qName":"A","qFieldSelectionMode":"NORMAL"}],"qNotSelectedFieldSelectionInfo":[],"qSelectionThreshold":6}]
my-angular-module.js:59 ["A"]
my-angular-module.js:72 []
my-angular-module.js:78 [{…}]


my-angular-module.js:112 n {OnData: n, qapp: S, selections: Array(1), stateName: "$", …}
my-angular-module.js:115 [e]
my-angular-module.js:140 S {fieldCache: {…}, stateCache: {…}, qEvent: t, close: ƒ, id: "1d0e9665-1a42-41ca-bd4c-4552fdff4dc7", …}
my-angular-module.js:143 App {_super: undefined, rpcOptions: {…}, session: d, waitForOpen: u, notification: ƒ, …}
my-angular-module.js:145 apply selections
my-angular-module.js:40 [{"qTotal":5,"qField":"COl1","qSelectedCount":1,"qSelected":"A","qRangeInfo":[],"qSortIndex":0,"qStateCounts":{"qLocked":0,"qSelected":1,"qOption":0,"qDeselected":0,"qAlternative":4,"qExcluded":0,"qSelectedExcluded":0,"qLockedExcluded":0},"qSelectedFieldSelectionInfo":[{"qName":"A","qFieldSelectionMode":"NORMAL"}],"qNotSelectedFieldSelectionInfo":[],"qSelectionThreshold":6}]
my-angular-module.js:59 ["A"]
my-angular-module.js:72 []
my-angular-module.js:78 []

 

Labels (2)
2 Replies
treysmithdev
Partner Ambassador
Partner Ambassador

Could it be that your session in the first app is closing when switching to the second app? 

Blog: WhereClause   Twitter: @treysmithdev
amitghaste
Contributor II
Contributor II
Author

I found the answer for this.

it has to do with 

 

fld.selectValues( valArray, true, true )

 

should instead be

fld.selectValues( valArray, false, true )

 

 For some reason, the toggle attribute does not seem to work as I was expecting it too.