Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pre populated values in dropbox in qvpp?

Hi all,

is it possible to have pre populated values in extension properties panel? My idea is to have a dropbox from which user can select the extension chart type (something like bar, line, combo) but the cart types are not defined as field/dimension.

Thanks!

Stefan

1 Solution

Accepted Solutions
ErikWetterberg

Yes, its possible. With version 11 it is included in the framework, in version 10 you need to add it in your extension code.

In the qvpp file you write something like this:

<select avq='textSelect:.Chart.Text.0.Content'>

         <option value="topleft">Top Left</option>

         <option value="topright">Top Right</option>

         <option value="bottomleft">Bottom Left</option>

         <option value="bottomright">Bottom Right</option>

</select>

The textSelect object is included in version 11, in 10 you can create it like this:

if (Qva.Mgr.textSelect == undefined) {

    Qva.Mgr.textSelect = function(owner, elem, name, prefix) {

        if (!Qva.MgrSplit(this, name, prefix)) return;

        owner.AddManager(this);

        this.Element = elem;

        this.ByValue = true;

        elem.binderid = owner.binderid;

        elem.Name = this.Name;

        elem.onchange = Qva.Mgr.textSelect.OnChange;

        elem.onclick = Qva.CancelBubble;

   }

   Qva.Mgr.textSelect.OnChange = function() {

    var binder = Qva.GetBinder(this.binderid);

    if (!binder.Enabled) return;

    if (this.selectedIndex < 0) return;

    var opt = this.options [this.selectedIndex];

    binder.Set (this.Name, 'text', opt.value, true);   

   }

   Qva.Mgr.textSelect.prototype.Paint = function(mode, node) {

        this.Touched = true;

        var element = this.Element;

        var currentValue = node.getAttribute("value");

        if (currentValue == null) currentValue = "";

        var optlen = element.options.length;

        element.disabled = mode != 'e';

        for (var ix = 0; ix < optlen; ++ix) {

             if(element.options[ix].value === currentValue){

                element.selectedIndex = ix;

             }

        }   

        element.style.display = Qva.MgrGetDisplayFromMode(this, mode);       

   }

}

View solution in original post

4 Replies
ErikWetterberg

Yes, its possible. With version 11 it is included in the framework, in version 10 you need to add it in your extension code.

In the qvpp file you write something like this:

<select avq='textSelect:.Chart.Text.0.Content'>

         <option value="topleft">Top Left</option>

         <option value="topright">Top Right</option>

         <option value="bottomleft">Bottom Left</option>

         <option value="bottomright">Bottom Right</option>

</select>

The textSelect object is included in version 11, in 10 you can create it like this:

if (Qva.Mgr.textSelect == undefined) {

    Qva.Mgr.textSelect = function(owner, elem, name, prefix) {

        if (!Qva.MgrSplit(this, name, prefix)) return;

        owner.AddManager(this);

        this.Element = elem;

        this.ByValue = true;

        elem.binderid = owner.binderid;

        elem.Name = this.Name;

        elem.onchange = Qva.Mgr.textSelect.OnChange;

        elem.onclick = Qva.CancelBubble;

   }

   Qva.Mgr.textSelect.OnChange = function() {

    var binder = Qva.GetBinder(this.binderid);

    if (!binder.Enabled) return;

    if (this.selectedIndex < 0) return;

    var opt = this.options [this.selectedIndex];

    binder.Set (this.Name, 'text', opt.value, true);   

   }

   Qva.Mgr.textSelect.prototype.Paint = function(mode, node) {

        this.Touched = true;

        var element = this.Element;

        var currentValue = node.getAttribute("value");

        if (currentValue == null) currentValue = "";

        var optlen = element.options.length;

        element.disabled = mode != 'e';

        for (var ix = 0; ix < optlen; ++ix) {

             if(element.options[ix].value === currentValue){

                element.selectedIndex = ix;

             }

        }   

        element.style.display = Qva.MgrGetDisplayFromMode(this, mode);       

   }

}

Not applicable
Author

Hi Erik,

thanks for your reply. I've put the js code into QvAjaxBaseMgr.js and edited the qvpp file but when try to get the value from the dropbox (this.Layout.Text0.text) i've got and empty string. Did i miss something?

Thanks!

Stefan

ErikWetterberg

Hi Stefan,

Getting the properties value in the extension javascript code can be a bit tricky. In my extension I do like this:

var legendPos = this.Layout.Text0 ? this.Layout.Text0.text : "bottomright";

Also I think you should avoid modifying the standard scripts, do not put any code in QvAjaxBaseMgr.js, it might not work (since the minified QvAjax.js is the file that is actually used) and you will have problems installing it and upgrading your server. You can create the textSelect object in the extensions javascript file but not in the AddExtension function.

And when you add properties to your extension you need to remove the object from the document and add it back again.

Not applicable
Author

Thank you very much Erik!!! I works perfect.

I know that i must not change the core files but this is my first (and test) extension which will not be distribute to any server

Thanks again for you help!

Stefan