Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
Lee_Matthews
Former Employee
Former 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")

}

1 Solution

Accepted Solutions
Lee_Matthews
Former Employee
Former Employee
Author

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*/

} )

View solution in original post

3 Replies
Lee_Matthews
Former Employee
Former Employee
Author

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*/

} )

BI_Dev
Creator II
Creator II

Here app.clearAll(); will clear all the selections from the app..can we just limit the clear all to only few object s (Highlighted below)

 

//get objects -- inserted here --
app.getObject('QV7','nkqrQX');
app.getObject('QV8','grjMbPe');
app.getObject('QV9','ExJF');
app.getObject('QV00','e10b830b-dd35-49ee-9e12-9624f9888677');

qlik.theme.apply('next-gen-theme');

//create cubes and lists -- inserted here --

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

app.clearAll();

});

SN
Contributor II
Contributor II

Hello everyone, 

I have tried both solution and didn't work for me, i need to make a clear button in mashup to clear all selections