Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi everyone,
Could anyone tell me how to use the setOptions method of the visualization API (setOptions method ‒ Qlik Sense Developers) to set the attributes of a dimension?
The following code can be used to change title, subtitle and footnote:
app.visualization.get(strQID).then(function(vis){
console.log('vis',vis);
vis.setOptions(
{
//orientation:"vertical"
title:"New title",
subtitle:"New subtitle",
footnote:"New footnote"
});
According to the help, I should be able to set all of these properties: http://help.qlik.com/en-US/sense-developer/September2017/Subsystems/APIs/Content/CapabilityAPIs/Visu...
, but the example is rather simplistic and doesn't cover how to interact with the attributes.
Thanks in advance.
That looks like a bug in the documentation. I would be very surprised if setting it through the API works when you cannot do it in the client.
Erik Wetterberg
Eureka! I got it to work with the table by replacing the qDef with the qExpression property, so it now looks like this:
if(strQID=='ueBFGP')
{
vis.setOptions(
{
title:"New title",
subtitle:"New subtitle",
footnote:"New footnote",
qHyperCubeDef:
{
qDimensions:
{
0: {
qDef: {autoSort:false} ,
"qAttributeExpressions":
[
{
"id": "cellBackgroundColor",
"qExpression":"=Red()"
}
]
}
}
}
});
}
Perhaps it is a mistake in the documentation since when I tried the same approach that worked for the table, it didn't work for the pivot table. While in the table, setting "qExpression":"=Red()" showed "qExpression":"=Red()" in the console, it showed as qFallbackTitle:"=Red()" for the pivot table, which makes me think that it's not possible.
Thanks for all your help Erik