Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser09
Creator II
Creator II

Mashup - Integrating two apps and trying to apply a common filter

Integrating two apps but the filters are applying only for the respective charts and not for the charts from the other apps.

Attached is the Json code , which includes 2 charts and 2 filters(1 chart and 1 filter for each app respectively) from 2 different apps. 

var app = qlik.openApp('app', config);

var app1 = qlik.openApp('app1', config);

function AppUi ( app ) {

var me = this;

this.app = app;

app.global.isPersonalMode( function ( reply ) {

me.isPersonalMode = reply.qReturn;

} );

app.getAppLayout( function ( layout ) {

$( "#title" ).html( layout.qTitle );

$( "#title" ).attr( "title", "Last reload:" + layout.qLastReloadTime.replace( /T/, ' ' ).replace( /Z/, ' ' ) );

//TODO: bootstrap tooltip ??

} );

app.getList( 'SelectionObject', function ( reply ) {

$( "[data-qcmd='back']" ).parent().toggleClass( 'disabled', reply.qSelectionObject.qBackCount < 1 );

$( "[data-qcmd='forward']" ).parent().toggleClass( 'disabled', reply.qSelectionObject.qForwardCount < 1 );

} );

app.getList( "BookmarkList", function ( reply ) {

var str = "";

reply.qBookmarkList.qItems.forEach( function ( value ) {

if ( value.qData.title ) {

str += '<li><a data-id="' + value.qInfo.qId + '">' + value.qData.title + '</a></li>';

}

} );

str += '<li><a data-cmd="create">Create</a></li>';

$( '#qbmlist' ).html( str ).find( 'a' ).on( 'click', function () {

var id = $( this ).data( 'id' );

if ( id ) {

app.bookmark.apply( id );

} else {

var cmd = $( this ).data( 'cmd' );

if ( cmd === "create" ) {

$( '#createBmModal' ).modal();

}

}

} );

} );

$( "[data-qcmd]" ).on( 'click', function () {

var $element = $( this );

switch ( $element.data( 'qcmd' ) ) {

//app level commands

case 'clearAll':

app.clearAll();

app1.clearAll();

break;

case 'back':

app.back();

app1.back();

break;

case 'forward':

app.forward();

app1.forward();

break;

case 'lockAll':

app.lockAll();

app1.lockAll();

break;

case 'unlockAll':

app.unlockAll();

app1.unlockAll();

break;

case 'createBm':

var title = $( "#bmtitle" ).val(), desc = $( "#bmdesc" ).val();

app.bookmark.create( title, desc );

$( '#createBmModal' ).modal( 'hide' );

break;

}

} );

}

//get objects -- inserted here --

app1.getObject('filter1','9185272');

app1.getObject('QV03','c5ba1');

app1.getObject('filter2','1fe17');

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

if ( app ) {

new AppUi( app );

}

 

var appSelectionviaAPI=false;

var app1SelectionviaAPI=false;

 

var selState = app.selectionState( );

var listener = function() {

         

         app1.clearAll();

            var selFields = selState.selections;

var cacheString="";

 

if (selFields!=null){

$.each(selFields, function(key, value) {

var valArray=[];

$.each(value.selectedValues, function(key,value){

isNaN(value.qName) ? valArray.push(value.qName):valArray.push(Number(value.qName));

})

cacheString=cacheString + '@' + value.fieldName +"~" + value.qSelected;

app1.field(value.fieldName).selectValues(valArray);

 

 

});

localStorage.setItem("QlikFilter",cacheString);

}

 

          };

          selState.OnData.bind( listener );

retrieveSelectionfromCache();

 

function retrieveSelectionfromCache()

{

var cacheString= localStorage.getItem("QlikFilter");                

if (cacheString!=null && cacheString !=""){

app.clearAll();

var selFields=cacheString.split("@");        

 

$.each(selFields, function(key, value) {

if (value!=null && value!=""){

var valArray=[];

var s = value.split("~");

var fieldName=s[0];

valArray = s[1].split(", ");                                

app.field(fieldName).selectValues(valArray);

}

});

}

else{

app.clearAll();

}        

}

Labels (1)
0 Replies