Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
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!

35 Replies
Alexander_Thor
Employee
Employee

Yea, you could potentially store your lat/long bounds as a property on the object and as the object paints look for those bounds and re-position. Would work in Stories also as it's a copy of the state of the object of the time of snapshot.

Now how efficient storing that on the object is I don't know.

bryan_sng
Partner - Creator
Partner - Creator
Author

Hmm I does have a lot to store like which layer is now visible, what is the zoom level, longitude, latitude, what basemap is used, etc. I came across the mashup api qlik.app.variable.create, do you think it is feasible? I was thinking capturing all the content via a json string in the properties of the extension is a little weird.

Btw, a little sidetrack, is there anyway to open up a standard qlik selection box programmatically?

(the one with the lasso icon that is open up via this.selectValues(dim, [value], true) but I do not have value to select)

ErikWetterberg

Congratulations!

Your are the first one I know to use Alternate states in a Qlik Sense extension. Is this something you could share, for example at Branch?? If not I would be interested in a copy myself.

Erik

bryan_sng
Partner - Creator
Partner - Creator
Author

I'm just glad I got this working for my client context!

Sharing as in the entire extension?

I does post an extract of the solution to aid those who have the same problem as me.

bryan_sng
Partner - Creator
Partner - Creator
Author

For anyone who is using this solution, I just want to add that this solution will not work if user is already in selection mode.

For example you are selecting an item from a table and you are using the selected data to retrieve some other data from the data store, the selectValues method will fail because selectValues cannot execute when application is already in the selection mode context.

I am using another solution by openApp instead. This also allow us to have 2 different selection container that does not conflict with each other although the clean up is having a little issue. A separate topic was opened instead:

qlik.openApp and qlik.close

bryan_sng
Partner - Creator
Partner - Creator
Author

For anyone following this thread, I realise addAlternateState has more problem, it turn out that whenever there is a current selection that intersect with the result from createCube, the result from createCube will be filtered to the current selection.

Here's an example:

Assuming there is no selection at qlik selection bar, the following codes will return 4 product ids:

1111

2222

3333

4444

/****************

var temp1 = qlik.currApp();

var sttate = '123456890';

temp1.addAlternateState(sttate).then(function() {

  temp1.field('Postal Code', sttate).clear();

  temp1.field('Postal Code', sttate).selectValues([109441, 328958], false, true).then(function() {

    temp1.createCube({

      qStateName: sttate,

      qDimensions: [{ qDef : { qFieldDefs : ['Product ID'] } }],

      qMeasures: [],

      qInitialDataFetch: [{

        qTop: 0,

        qLeft: 0,

        qWidth: 1,

        qHeight: 10000

      }]

    }, function(reply) {

      console.log(reply.qHyperCube.qDataPages[0].qMatrix);

      temp1.destroySessionObject(reply.qInfo.qId).then(function() {

        temp1.removeAlternateState(sttate);

      });     

    });

  });

});

****************/


Now assuming there is a selection of product id 1111 at the qlik selection bar,

the same code will return just 1 product id:


1111


It's not as expected as alternate state is suppose to be a separate container, anyone got any ideas?

Just for info I'm exploring alternate state again because openApp strategy cannot support multiple users.


Finally, just to reiterate, the main objective is to query data from qlik without using dimension, just in case anyone got any more better strategy after the release of 2.0.1



ErikWetterberg

When you create an alternate state it will start with a copy of the default state, that is intentional.

Erik

bryan_sng
Partner - Creator
Partner - Creator
Author

Hmm interesting, is there anyway I can clear all the selection in the alternate state?

I know for sure I cannot use app.clearAll() because that will wipe out my qlik selection bar instead of the alternate state.

Alternatively I think i can get the extension dimensions via layout, then do a loop on each of the dimension before executing app.field(dimension, stateName).clear() on them but it seems cumbersome.

Additionally, is there anyway to perform app.field(...).clear and app.field(...).selectValues without messing with the qlik selection bar?

I'm trying to do some clear and selectValues but I do not want the user to see them when clicking on the previous selection at the qlik selection bar.

Thanks!

ErikWetterberg

Hi,

You should be able to clear selections in an alternate state with clearAll() method, but I'm afraid the state parameter is missing from that call. This is a bug, I'll see to it that it gets fixed for the next version (probably 2.1).

Erik

bryan_sng
Partner - Creator
Partner - Creator
Author

Sounds great to me! I will temporarily wrap those cumbersome calls and wait for the fix in 2.1.

Hmm do you have any ideas about the selection history?

Any methods not to store them when clear or selectValues (maybe like an optional parameter)?

Oh, recently I been looking more into engine API.

Then I play around with the protocol tester and realise getTableData (recommend earlier by yko) is able to get data directly too.

However there is no filter I can provide as a params, do you have any advice to get data directly using engine API?

Hmm, if only there is some way I can get data from qlik application data store like SQL, that would be super fantastic!