getObject method
This API is reliable and breaking changes are unlikely.
qlik.app.getObject(elem, id, options)
Retrieves a Qlik Sense object from the Qlik Sense application and inserts it into a HTML element. The object fills the HTML object, so you can size and position the element to determine how large the Qlik Sense object will be.
If you supply only one parameter, you get the model without displaying the object.
Version history
Version state | Details |
---|---|
Introduced | 1.0 |
Updated | 1.1, 3.0, Qlik Sense November 2017 |
Disclaimer
The element that is provided as a parameter to the getObject method must have CSS property position set to relative and must not have any padding.
If these rules are not followed, the visualization object may not calculate its width and height correctly and you may not be able to scroll and navigate after toggling data view.
Proposed action
Wrap the element with another element. The wrapper can then be styled without any limitations.
Parameters
elem
Type: Element | String
Optional.
HTML element.
Since version 1.1 it is also possible to define a string of the HTML element ID.
id
Type: String
Defines the ID of the object. Can be one of:
- Object ID
- 'CurrentSelections' if used for Selections bar
- 'AppNavigationBar' if used for On-Demand App Navigation bar (Added in Qlik Sense November 2017)
options
Type: Object
Optional.
Name | Type | Description |
---|---|---|
noInteraction | Boolean |
Set to true if you want to disable interaction, including selections, in the visualization. Introduced in version 1.1 and updated in version 3.0. |
noSelections | Boolean |
Set to true if you want to disable selections in the visualization. Introduced in version 3.0. |
sheetId | String |
Mandatory if id='AppNavigationBar', otherwise not used. Defines the sheet id where the App Navigation bar exists. Introduced in Qlik Sense November 2017. |
openAppCallback | Function |
Optional Applies only if id='AppNavigationBar'. Function used to define what happens when the user clicks the Open generated app button. If undefined, the generated app is opened in a new tab. The function callback returns appId and targetSheetId. Introduced in Qlik Sense November 2017. |
Returns
A promise of an object model or, for visualizations, a QVisualization model.
Example
Example: Get object defining the html element
var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d', config);
app.getObject(document.getElementById("LB01"),
"uPyZavD");
Example: Get object defining the element id string
var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d', config);
app.getObject("LB01","uPyZavD");
Example: Get object with On-demand App Navigation bar
var app = qlik.openApp('2abac31e-3b46-4b78-8bxf-c5cea1d2514d', config);
app.getObject('MyAppNavigationToolbarDIVid', 'AppNavigationBar', {
sheetId: "RWcstb", openAppCallback: function ( appId, targetSheetId ) {
alert("Open generated app event handled. App ID: " + appId + " target sheet to open by default: " + targetSheetId);
}
}
);