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

Passing data from qv to extension

I wrote a D3 dependency relationship mapping extension to utilize the data selected in QV. My problem is passing the expression to the extension. Do you simply put the expressions in the Definition.xml and then it can be accessed using _this.Data.Rows?

I am trying that with no luck....

Definition.xml

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

<ExtensionObject Label="d3Bar" PageHeight="100000" Path="d3Bar" Description="" Type="object" >

  <Dimension Label="Node Name" Initial="=Only(Capability)" TargetName="Dimension Name" />

  <Dimension Label="Node Description" Initial="=[Capability Definition]" TargetName="Dimension Name" />

  <Measurement Label="Entity Type" Initial="=[Support Type]"/>

  <Measurement Label="Target level 0" Initial=""/>

  <Measurement Label="Target level 1" Initial=""/>

  <Initiate Name="Chart.Title" value="Dependency View" />

  <Initiate Name="Caption.Text" Value="Dependency View" />

</ExtensionObject>

Accessing the data:

for (var i = 0; i < _this.Data.Rows[0].length; i++) {

  // get the row

  var row = _this.Data.Rows[0];

  console.log(row);

}

1 Solution

Accepted Solutions
Not applicable
Author

So it appears to be working now, when I manually add the dimensions and expressions using the desktop application. Might have to investigate later how to make it automatically retrieve the expression and dimensions using the definition.xml but for now its working.

Delete the DynProperties.qvpp file.

If your Definition.xml had 2 Dimension and 3 Expressions, and create an extension object in the application, DynProperties.qvpp will be created when you add an object in it.

Then you change Definition.xml by adding one more Dimension, this will not update existing extension object in your application, and DynProperties.qvpp will not get updated.  Therefore, you need to delete the extension object used in your application first, and then close the application and delete the DynProperties.qvpp (I am not 100% sure if this is a necessary step or not) , then add it back in your application.  You will have updated DynProperties.qvpp and if you check your data using firebug, you will see new dimension is available to use during data initialization.

One more follow up question. Passing the data to the extension, how can I pass an array of data. An example would be such as passing all the models for the selected car maker and the description, so if toyota is selected, then getting [Toyota: {'Camry', 'a luxury sedan'}, {'Corolla', 'a mid-size sedan'}]

is that possible?

Yes, it is possible.

All data from QlikView is coming in as a tabular format.

i.e. if your Dimension is Maker, Model, Type, Month-Year, and your expression is Sum(Sales).

Your Definition.xml should have 3 Dimensions and 1 Measurement.  If you want to pass a color, then add a Text.

i.e.

     <Dimension Label = "Maker", Initial="Maker" TargetName="Maker"/>

      <Dimension Label = "Model", Initial="Model" TargetName="Model"/>

      <Dimension Label = "Type", Initial="Type" TargetName="Type"/>     

      <Measurement Label="Sales" Initial="SUM(Sales)" TargetName="Sales" />

      <Text Label="Color" Initial="#AF8DC3" />

In your Script.js

......

function InitSettings() {

// General Settings

// Chart Object ID: used to create a Unique Chart ID

_this.ExtSettings.UniqueId = _this.Layout.ObjectId.replace("\\", "_");

// Use _this.ExtSettings.Color in your main script if you want to setup the color of something.

_this.ExtSettings.Color = _this.Layout.Text0.text;

}

function InitData() {

    

     var dataset = [];

     for (var i = 0; i < _this.Data.Rows.length; i++)

     {

           var vMaker     = _this.Data.Rows[0].text;

           var vModel     = _this.Data.Rows[1].text;            

           var vType       = _this.Data.Rows[2].text;

           var vSales = parseInt(_this.Data.Rows[3].text);

         

           // I just put all data from the row into one node.       

           dataset.push({"Maker":vMaker , "Model":vModel     , "Type":vType       , "Sales":vSales , "index":i});

     }

...

Hopefully this helped.

Sean

View solution in original post

13 Replies
Clever_Anjos
Employee
Employee

You should put your expression into object properties at design time.

Right Click your object and set your expressions

Clever_Anjos
Employee
Employee

Into your loop you´re retrieving the columns of your first line.

In order to retrieve all lines

_rows = this.Data.Rows;

for(i=0,k=_rows.length;i<k;i++){ // loopinf through all lines

  var x = _rows[0].text;// First column, probably your dimensio

  var y = _rows[1].text;// Second column

}

Not applicable
Author

The problem was that nothing is displayed in design time inside the box created (using the extension) as it uses HTML5. Thats why i thought it might not work setting the expressions there. However, I was able to right click and add the properties fine.

However, it doesnt get passed to the extension still. I used the code you provided and even did

console.log(_this);

but the array Rows is always empty

Clever_Anjos
Employee
Employee

Its strange because you have 2 dimensions and 3 expressions and your screen shows only 2 expressions.

Is it possible to post a qar?

Not applicable
Author

you are right, I only have 2 expressions right now as I am just testing to see it work.

it seems to be working now randomly. The extension in the document doesnt seem to always refresh right even if refresh the page, but at least its working now.

Not applicable
Author

Also the definition Dimension and Measurement dont seem to appear as they should and the qvpp file doesnt get generated, we have QV 11 SR2, is there anyway to force it to generate the qvpp file and read the definition.xml?

Clever_Anjos
Employee
Employee

Could you post your extension or send it to me?

I´ll help you.

I would upgrade to 11.20SR5 too

Not applicable
Author

If you added the extension object in your application, and then you added more dimensions or expressions in the Definition.xml, then you need to delete the object from your application and then create it again. 

Your qvpp will be updated and all your new dimensions or expressions will show up.

Sean

Not applicable
Author

So it appears to be working now, when I manually add the dimensions and expressions using the desktop application. Might have to investigate later how to make it automatically retrieve the expression and dimensions using the definition.xml but for now its working.

One more follow up question. Passing the data to the extension, how can I pass an array of data. An example would be such as passing all the models for the selected car maker and the description, so if toyota is selected, then getting [Toyota: {'Camry', 'a luxury sedan'}, {'Corolla', 'a mid-size sedan'}]

is that possible?