Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a requirement for user to be able to add a number of dimensions to a table in one step, without editing the extension and having to add the one by one. There is also a requirement that the data be exportable.
I was able to get the list of fields by calling app.getList("DimensionList" ..), passing the dimensions to createCube(), and rendering the resulting Hypercube to a table. This approach works, but the data is not available for export from the export context menu. I think I need to do one of the following:
Is number one even possible?
Number two seems like the correct option. Is using applyPatches() with operation "add" the right way to do it? Assuming it is, I have the following questions:
Any pointers in the right direction would be greatly appreciated.
Hi,
Yes, applyPatches() is the right call to use for this. I once wrote a short guide to it, you find it here:
https://extendingqlik.upper88.com/guide-to-qlik-sense-applypatches/
If you are using dimensions (which is what you get from DimensionList), the key property that needs to be set is qLibraryId. I think everything else is optional. You find the complete structure here:
https://help.qlik.com/en-US/sense-developer/April2020/APIs/EngineAPI/definitions-NxDimension.html
qInterColumnSortOrder is an array that determines in which order columns are used for sorting. Start with not setting it, that will give you the default, which is 0,1,2....
Hope this helps
Thank you for your reply, Erik.
Unfortunately I misspoke earlier when I said I was using getList( "DimensionList" ). This call returns an empty array. I was actually calling getList( "FieldList" ). It returns all the dimensions in the data source, but the objects do not contain the unique ID for the dimensions.
I tried creating a generic object of type qDimensionListDef, but it returned an empty list. I also tried defining the qDimensionListDef in the initial properties, but it too was an empty list.
I should add the Hypercube is populated with data and appears to work as expected.
Is there some other way to get the dimension IDs?
Are there dimensions defined in the app? If getList("DimensionList") returns an empty array there might not be any.
To use qDimensionListDef you also need to set qType to 'dimension'. For an example, check here:
https://extendingqlik.upper88.com/accessing-system-data-and-variables-in-a-qlik-sense-extension/
If there are no dimensions defined, you need to use the FieldList instead (or define dimensions..).
What I ended up doing was create a hypercube with the list of fields as dimension, and then stashing the context returned in the promise into a variable. Subsequent data fetches use this context instead of the on in the main app to get data.