Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
rbartley
Specialist II
Specialist II

Qlik Sense Visualization API - How to set cell attributes

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.

12 Replies
ErikWetterberg

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

rbartley
Specialist II
Specialist II
Author

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()"

}

]

}

}

}

});

}

rbartley
Specialist II
Specialist II
Author

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