Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Employee
Employee

Function in Mashup to Clear All Selections

I have a custom webpage on an IIS server with some mashup content plugged in. It is working fine. I need to add a button to allow the user to clear selections. The mashup API has a method called clearAll() here which I should be able to use. However I am not sure how to implement this. The javascript file associated with my mashup is attached. an extract is below.


- I can see that the connection to the app is defined in the first block of code.

- When I reference the app object in the second block it does not work

- I am guessing the second function needs to somehow be embedded into the first block, is that correct?

- I dont quite understand the requireJS syntax, so I am a little lost on h


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

  qlik.setOnError( function ( error ) {

  alert( error.message );

  } );

  //callbacks

  //open app and get objects

  var app = qlik.openApp("Thread Bare Clothing Sales.qvf", config);

  $(".qvobject").each(function() {

  var qvid = $(this).data("qvid");

  app.getObject(this, qvid);

  });

  /*AUTOGEN START*/

  /*AUTOGEN END*/

} );

function clearAll(){

  alert("start")

  app = qlik.currApp();

  app.clearAll();

  alert("end")

}

Tags (1)
1 Solution

Accepted Solutions
Employee
Employee

Re: Function in Mashup to Clear All Selections

To anyone interested in the solution, one of my (very) esteemed colleagues suggested the following approach which worked perfectly.


Add this to your HTML

<div id="ClearAll"><button>Click me</button></div>

And then add to the JavaScript what it should do when clicked (below in Red)

var config = {

      host: window.location.hostname,

      prefix: "/",

      port: window.location.port,

      isSecure: window.location.protocol === "https:"

};


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

      //open app and get objects

      var app = qlik.openApp("Barcelona Basecamp.qvf", config);

$(".qvobject").each(function() {

var qvid = $(this).data("qvid");

app.getObject(this, qvid);

      });

 

      $("#ClearAll").click(function() {

app.clearAll();

      });

     

/*AUTOGEN START*/

/*AUTOGEN END*/

} )

1 Reply
Employee
Employee

Re: Function in Mashup to Clear All Selections

To anyone interested in the solution, one of my (very) esteemed colleagues suggested the following approach which worked perfectly.


Add this to your HTML

<div id="ClearAll"><button>Click me</button></div>

And then add to the JavaScript what it should do when clicked (below in Red)

var config = {

      host: window.location.hostname,

      prefix: "/",

      port: window.location.port,

      isSecure: window.location.protocol === "https:"

};


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

      //open app and get objects

      var app = qlik.openApp("Barcelona Basecamp.qvf", config);

$(".qvobject").each(function() {

var qvid = $(this).data("qvid");

app.getObject(this, qvid);

      });

 

      $("#ClearAll").click(function() {

app.clearAll();

      });

     

/*AUTOGEN START*/

/*AUTOGEN END*/

} )

Community Browser