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:
Find a way to get the export function to point at the Hypercube that was created with createCube() so users can download an Excel workbook.
Modify the extension's Hypercube that is defined in its initialProperties at runtime to include new dimensions.
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:
Does the entire structure of the elements in qHyperCubeDef.qDimensions have to be given, or can I just set the dimension name?
Can I just set the dimension's qIdto any random value, or does this value have to be looked up someplace?
Is qHyperCubeDef.qInterColumnSortOrder always just a list from 0 to N? Does it have to be explicitly set?
Any pointers in the right direction would be greatly appreciated.
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.
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.