Qlik Community

Qlik Sense Integration, Extensions, & APIs

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

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor II
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;

       })

    }

  }

});

1 Solution

Accepted Solutions
Highlighted
Employee
Employee

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))

    })

View solution in original post

7 Replies
Highlighted
Contributor II
Contributor II

May be answer can be in Engine API?

Highlighted
Employee
Employee

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.

Highlighted
Contributor II
Contributor II

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?

Highlighted
Employee
Employee

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))

    })

View solution in original post

Highlighted
Contributor II
Contributor II

It works greats! Thank you!

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

Highlighted
Employee
Employee

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.

Highlighted
Partner
Partner

Hi akl,

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

Thanks,

Seb.