Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

mdbender
New Contributor II

Get data from table or chart

Hi all!

I'm new with qlik sense and it's API.

I've made extension which paints button. We have table with manages and another table with their results. After selecting manager content of the second tables filled with his results. How can I reach this data in my extension after clicking button?

define(["jquery", "qlik", "text!./lib/css/CommandButton2.css"], function($, qlik, cssContent) {

  $("<style>").html(cssContent).appendTo("head");

    return {

     paint: function ($element, layout) {

       // Display Extension Visualization
       var html = html = '<button id="modal-open2" class="btn btn-primary">Work</button>';

      $element.html(html);

    

       // Open modal
       $("#modal-open2").on('click', function(){

         alert('ok');

         console.log('Data returned: ', layout.qMadeSelections);

         // Do some job
         return false;

       })

    }

  }

});

Tags (2)
1 Solution

Accepted Solutions
Employee
Employee

Re: Get data from table or chart

Properties of an object does not contain data, only the expanded layout does. And in the case of native visualizations very few actually contain the data upfront but rather it is paged in on a need basis.

However is some code to fetch pages of data from a object.

And here is the interactive version of said code: Get Object Data - JSFiddle

    const app = qlik.openApp('d7b1f94e-749b-479a-9bad-fcb8fccda5dc', config);

    

    app.getObject("rJFbvG").then(model => {

      // Contains the full size of the hypercube, qcx which is the width

      // or number of columns and qcy the height or number or rows

      console.log(model.layout.qHyperCube.qSize);

   

      // Fetch a page of data. A single page can maximum contain 10000

      // cells. Calculate the page size and number of pages based of qSize

      // and fetch accordingly.

      model.getHyperCubeData('/qHyperCubeDef', [{

        qTop: 0,

        qLeft: 0,

        qWidth: 10,

        qHeight: 1000

      }]).then(data => console.log(data))

    })

7 Replies
mdbender
New Contributor II

Re: Get data from table or chart

May be answer can be in Engine API?

Employee
Employee

Re: Get data from table or chart

I'm not sure what you are looking to do but the Capabilities API has a method called getObject which lets you fetch other objects beside your extension.

mdbender
New Contributor II

Re: Get data from table or chart

Thank You! I find this page - https://help.qlik.com/en-US/sense-developer/3.1/Subsystems/EngineAPI/Content/Classes/AppClass/App-cl...

I added this code

// object table
console.log('Data returned: ', qlik.currApp().getObject("pKYZVU"));

// properties of object
qlik.currApp().getObjectProperties("pKYZVU").then(function(model) {
  console.log('Data returned: ',model.properties);
});

But I still can't find data from table in this object. What to do for fetching them?

Employee
Employee

Re: Get data from table or chart

Properties of an object does not contain data, only the expanded layout does. And in the case of native visualizations very few actually contain the data upfront but rather it is paged in on a need basis.

However is some code to fetch pages of data from a object.

And here is the interactive version of said code: Get Object Data - JSFiddle

    const app = qlik.openApp('d7b1f94e-749b-479a-9bad-fcb8fccda5dc', config);

    

    app.getObject("rJFbvG").then(model => {

      // Contains the full size of the hypercube, qcx which is the width

      // or number of columns and qcy the height or number or rows

      console.log(model.layout.qHyperCube.qSize);

   

      // Fetch a page of data. A single page can maximum contain 10000

      // cells. Calculate the page size and number of pages based of qSize

      // and fetch accordingly.

      model.getHyperCubeData('/qHyperCubeDef', [{

        qTop: 0,

        qLeft: 0,

        qWidth: 10,

        qHeight: 1000

      }]).then(data => console.log(data))

    })

mdbender
New Contributor II

Re: Get data from table or chart

It works greats! Thank you!

Why do you use "then(data => console.log(data))" but not "then(function(data) { // do job})"

Employee
Employee

Re: Get data from table or chart

It's ES6 syntax for arrow functions (not supported in all browsers) so you can safely use function() {} as well as it does the same thing.

sebastian_serva
New Contributor III

Re: Get data from table or chart

Hi akl,

How do you listen to model changes with your above approach? Traditional model.Validated.bind doesn't work.

Thanks,

Seb.

Community Browser