Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
I've got a following simple code:
var config = {
host: "sense-demo.qlik.com",
prefix: "/",
port: 443,
isSecure: true
}
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);
});
var app = qlik.openApp("d972b07b-fd90-466c-97be-b7aeecca29ee", config);
app.getObject($("#myDiv"), "cReWKcL");
app.field("Team Name").selectMatch("Cubs", false); //Here I'm trying to display a chart only for the Cubs team
});
And it appears to be non-deterministic. Once I get a one bar (only for the Cubs) and after few reloads I get a chart for all of the teams. And the other way around.
Could you provide some help regarding how to apply filtering on charts using JS API?
Thanks in advance
Aleksander
The methods are async so you can't rely on app.getObject to finish before you issue your selection.
Luckily all methods in the Capabilities API return a promise so you can establish some kind of flow control,
pseudo code:
app.getObject('mydiv', 'myobjectid').then(() => {
app.field('myfield').selectMatch('Cubs', false)
})