Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
In an extension, the rendering is done in the "paint" function.
For instance:
paint : function($element, layout) {
$element.html("Hello World!") ;
}
will display "Hello World!".
I would like to know how I can evaluate the string as a QlikView expression, something like that:
paint : function($element, layout) {
$element.html("=today()") ;
}
or
paint : function($element, layout) {
$element.html("='you have ' & count(DISINTCT Element) & ' elements'") ;
}
Thank you.
Hi,
You could set up an expression in your initial properties. Somthing like:
initialProperties : {
version : {
qStringExpression : "=QlikViewVersion ()"
},
fields : {
qValueExpression : "=Count (DISTINCT $Field)"
}
,......
this will give you version in the field layout.version and number of fields in layout.fields. If the values change, your paint method will be called again with the new values.
Erik
I tried to add this lines in my "initialProperties", but I cannot access to the new "layout.fields" and "layout.version".
(I'm using Firebug to explore the object "layout")
I'm trying to modify the "HTML Box" object, so it could compute the string:
define(["jquery","./com-itelligence-htmlBox-properties"], function($,properties) {
return {
type : "it.HTML Box",
//Refer to the properties file
definition : properties,
initialProperties : {
version: 1.0,
qHyperCubeDef : {
qDimensions : [],
qMeasures : [],
qInitialDataFetch : [{
qWidth : 0,
qHeight : 0
}]
},
fontSize : {
min : 8,
max : 24
},
test : {
qStringExpression : "=QlikViewVersion ()"
}
},
snapshot : {
canTakeSnapshot : false
},
paint : function($element, layout) {
//$element.html("$(" + layout.qDef['HTML'] + ")") ;
$element.html(layout.test) ;
//$element.html(layout.qDef['HTML']) ;
}
};
});
I've added a "test" property --> I can't access it with "layout.test".
My aim is to be able to set
='you have <b>' & count(DISTINCT $Field) & '</b> fields in your application'
in my HTML parameter, instead of a simple static string.
Since the initialProperties is used when you create the object, you need to recreate it.
It works better for a static value.
However, if the value is hard-coded, the user can't change it.