4 Replies Latest reply: Jan 23, 2015 8:01 AM by Nicolas MARTIN RSS

    How to display an evaluated expression?

    Nicolas MARTIN

      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.

        • Re: How to display an evaluated expression?
          Erik Wetterberg

          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

            • Re: How to display an evaluated expression?
              Nicolas MARTIN

              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.