Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bryan_sng
Partner - Creator
Partner - Creator

Qlik sense extension load data without dimension

Hello guys,

Is there any way I can access data from the app data model without using dimensions?

I understand I can access data via layout.qHyperCube.qDataPages[0] if I add the necessary dimensions in.

I also tried initialproperties such as the following but could not find it anywhere in the layout variable.

define([], function () {

  return {

    version: 1.0,

    qHyperCubeDef: {

      qDimensions: ['mytestproperty1', 'mytestproperty2'],

      qMeasures: [],

      qInterColumnSortOrder: [],

      qInitialDataFetch: [{

        qWidth: 3,

        qHeight: 400

      }]

    }

  };

});

Do you guys have any advice? Thanks!

1 Solution

Accepted Solutions
ErikWetterberg

Hi,

There is a timing issue here apparently. Try:

app.field(...).selectValues(...).then(function(){

  app.createCube(...);

});

Should fix that problem...

Yes, it would affect selection state. You could restore it with app.back() after you get the data.

Another possible solution (which I haven't tried, so I can not promise you that it works) is using an alternate state. You could create it with app.addAlternateState and then use it both when you get the field and when you create the cube.

Erik

View solution in original post

35 Replies
Øystein_Kolsrud
Employee
Employee

There is a method called "GetTableData" for apps that might be what you are looking for. It allows you to access data directly from the loaded tables without going through hypercubes or list objects. You can find more information here:

http://help.qlik.com/sense/en-us/developer/#../Subsystems/EngineAPI/Content/Classes/AppClass/AppClas...

Alexander_Thor
Employee
Employee

Take a look at https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/Workbench/Content/CodeExamples/... which shows you how to use a listobject def instead of a hypercube.

Also in your snippet you can't just pass in a string. You would pass in a NxDimension struc, you can see which properties you can set here https://help.qlik.com/sense/en-us/developer/index.html#../Subsystems/EngineAPI/Content/GenericObject...

But it would be something like

"qDimensions": [{

"qDef": "FieldName",

  "qNullSuppression": true

}, {

"qDef": "FieldName2",

"qNullSuppression": true

}]

bryan_sng
Partner - Creator
Partner - Creator
Author

Hmm both sounds like viable solution, let me give it a shot and see which suits me better, thanks!

bryan_sng
Partner - Creator
Partner - Creator
Author

Hmm I been trying out the GetTableData method but could not find the method within the app.

Am I doing it wrong?


    paint: function($element, layout) {

      var app = qlik.currApp();

      console.log(app.getTableData); // this is undefined

    }  

bryan_sng
Partner - Creator
Partner - Creator
Author

Hmm this does work but alas it will add the specified dimensions into the extension properties panel -> dimension section. So I guess its like some sort of predefined dimension rather than manually adding dimension in. Ultimately though, there are still many dimensions in the extension properties which our client do not want. I guess I may have to try out more in depth with Øystein Kolsrud solution, do you have any insight regarding why I could not find GetTableData method in the app object as replied above?

Øystein_Kolsrud
Employee
Employee

It looks like that engine API method is not exposed in the API you are using. I'll see if there is a workaround for it and get back to you.

ErikWetterberg

Hi Bryan,

I'm not totally sure what you are after. You could do this by setting up the field you want one or several qListObjectDef in your initialProperties in the extension. This is what Horizontal Listbox does, and many other extensions. If you want the user to be able to select the field in the properties panel, you should add a property panel definition like in Horizontal Listbox too.

The other way available to you is to use the qlik library and the method createList. To use that in an extension you first need to get a reference to the current app with the call qlik.currApp(this). Note that if you use this method, the callback function you provide for the createList method will be called not only once, but every time data changes (that is when the user makes a selection). If you need sveral lists, you can call createList multiple times.

If you do not want to be notified any more of selection changes you should use the method destroySessionObject. The id you should use would be in the createList reply.

Hope this helps

Erik

bryan_sng
Partner - Creator
Partner - Creator
Author

Hello Erik, thanks for the additional insight, to clarify, basically my extension need to display a map.

When user click on a point in map, it is suppose to get information from the data model based on the click source.

(E.g. I click on eiffel tower, it will display opening hours, height, description, how to get there, etc.)

These information are loaded currently into my data model.

In order to display these information, I can add each of these data as individual dimension

(e.g. opening hours - 1 dimension, height - 1 dimension, description - 1 dimension, etc)

This is do able but there are too many dimensions to be added (we got like 20+ information to display).

As such, we would like to be able to retrieve information directly from the app data model without going through dimensions.

qListObjectDef and qHyperCubeDef does work but they will add that 20+ dimensions to my extensions.

I need to find a way to get data without using dimensions.

Alexander_Thor
Employee
Employee

Hmm, I did something similar for my Google Maps extensions.

You could perhaps even get away with just having a single expression?

In the expression you could just build up a html formatted string and insert that into your popup.

Example: ='Location: ' & Only(LocationName) & '<br>' & 'Value: ' & Sum(Value)
It will then calculate all those values for you for that single dimensional value.