Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Using Expression in Definition.xml/Properties.qvpp/Script.js

Hey,

I want to have access via JavaScript to an expression which I have defined in the Definition.xml.

Definition.xml:

===========

<?xml version="1.0" encoding="utf-8"?>

<ExtensionObject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Definition.xsd" Label="EXTENSIONNAME">

    <Initiate Name="Caption.Text" Value="EXTENSIONNAME" />

    <Initiate Name="Caption.Font.Italic" Value="1" />

    <Initiate Name="Chart.BgColor.ColorHex" Value="#FFFFE0" />

    <Text Label="User" Expression="=OSUser()"/>

</ExtensionObject>

Properties.qvpp:

============

<div class="ToolWindow-MainBody" avq="foldOutMenu:." style="overflow: visible !important; float: left;">

  <div class="prop-accordion" avq="accordion:.">

    <h3 class="prop-h3 accordion-shadow">

      <a href="#">EXTENSIONNAME</a>

    </h3>

    <div class="prop-grid_container accordion-shadow-enabler" style="overflow:auto;">

      <div class="prop-grid_clear prop-grid_top-vertical-spacer-12px prop-grid_last"></div>

  </div>

    <h3 class="prop-h3 accordion-shadow" avq="activeAccordionHeader:.:GenericPresentationFoldout.qvpp">

      <a href="#">Presentation</a>

    </h3>

    <div class="prop-grid_container accordion-shadow-enabler" avq="panel::Layout.qvpp"></div>

    <h3 class="prop-h3 accordion-shadow" name="accordion-header" avq="activeAccordionHeader:.:PropertiesCaptionFoldout.qvpp">

      <a href="#">Caption</a>

    </h3>

    <div class="prop-grid_container accordion-shadow-enabler" avq="panel:.:Caption.qvpp"></div>

    <h3 class="prop-h3 accordion-shadow" name="accordion-header" avq="activeAccordionHeader:.:PropertiesOptionsFoldout.qvpp">

      <a href="#">Options</a>

    </h3>

    <div class="prop-grid_container accordion-shadow-enabler" avq="panel:.:ChartOptions.qvpp"></div>

<div class='prop-grid_clear prop-grid_prepend-1 prop-grid_span-5' avq='prop_label'>User:</div>

<div class='prop-grid_span-10 prop-grid_last'>

  <div class='popup-grid_span-7 popup-grid_last' style='width:94%;' avq='prop_editexpression:.Chart.Text.0.Content'></div>

</div>

  </div>

  <span class="bottom-gap"></span>

</div>

Script.js

======

var user = this.Layout.Text0.text;

What make I wrong, in the ObjectProperties window, there stands no text, also I haven' t this attribute in my JavaScript(this.Layout.(Text0 not there))

1 Solution

Accepted Solutions
patrik_seger
Partner - Creator
Partner - Creator

Hi

The code looks ok to me.

When there is a change in the Definition.xml file, you need to remove all extension objects of that type in the QV file and add them again. Have you tried that?

Br Patrik

View solution in original post

5 Replies
Alexander_Thor
Employee
Employee

Hey,

Look at the attached sample and it should give you an hint.

Unless you are building something for QV10 or you really really need a custom properties panel I would recommend that you make use of the automatic generation of properties that was introduced with QV11.

If you add a few more properties into your definition.xml, mainly a type property for your text tag, QlikView will generate a nice looking properties page for you.

Not applicable
Author

Hello Alexander,

thanks for your useful answer, I have test your file and this is working. Now I have use your "code" and copied to my project, but this is not working.

Definition.xml:Unbenannt.PNG

<?xml version="1.0" encoding="utf-8"?>

<ExtensionObject Label="MyExtension">

<Initiate Name="Caption.Text" Value="MyExtension" />

    <Initiate Name="Caption.Font.Italic" Value="1" />

    <Initiate Name="Chart.BgColor.ColorHex" Value="#FFFFE0" />

<Text Label="OSUser" Type="text" Initial="" Expression="=OSUser()"/>

</ExtensionObject>

Script.js:

function MyExtension_Done() {

    Qv.AddExtension("MyExtension",

        function() {

            var extensionName = "MyExtension";

            var extensionPath = Qva.Remote + "?public=only&name=Extensions/" + extensionName + "/";

             var _this = this;        

             var osuser = _this.Layout.Text0.text;

             ....

What is there the problem, I don't understand this.

Alexander_Thor
Employee
Employee

Are you running QV11 SR1 by any chance?

Not applicable
Author

I am using QV 11 SR 2

Unbenannt.PNG

Alex, do you have some tips for me;) I have my pseudo Extension uploaded as a zip file.

patrik_seger
Partner - Creator
Partner - Creator

Hi

The code looks ok to me.

When there is a change in the Definition.xml file, you need to remove all extension objects of that type in the QV file and add them again. Have you tried that?

Br Patrik