Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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;
})
}
}
});
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))
})
May be answer can be in Engine API?
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.
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?
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))
})
It works greats! Thank you!
Why do you use "then(data => console.log(data))" but not "then(function(data) { // do job})"
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.
Hi akl,
How do you listen to model changes with your above approach? Traditional model.Validated.bind doesn't work.
Thanks,
Seb.
This discussion helped me a lot can you please tell me what does it mean by '/qHyperCubeDef'.In docs I can get it as
qPath string | Path to the definition of the object to be selected. For example, /qHyperCubeDef . |
but I cant get a gist of it.Can you please explain more on this?
@maniratnagupta I've written a blog post on this topic that might be helpful. In particular, check out the "Getting Data" section here: