Last active
November 21, 2017 01:39
-
-
Save mindspank/cc07587300b4802de157 to your computer and use it in GitHub Desktop.
Hacky way to page data with multiple cubes in a single extension
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| define(["jquery", 'qvangular'], function ($, qv) { | |
| return { | |
| initialProperties: { | |
| qHyperCubeDef: { | |
| qDimensions: [], | |
| qMeasures: [], | |
| qInitialDataFetch: [{ | |
| qWidth: 2, | |
| qHeight: 1 | |
| }] | |
| }, | |
| secondcube: { | |
| qHyperCubeDef: { | |
| qDimensions: [{ | |
| qDef: { | |
| qFieldDefs: ["zip"] | |
| } | |
| }], | |
| qMeasures: [{ | |
| qDef: { | |
| qDef: '=Count(zip)' | |
| } | |
| }], | |
| qInitialDataFetch: [{ | |
| qWidth: 2, | |
| qHeight: 5000 | |
| }] | |
| } | |
| } | |
| }, | |
| definition: { | |
| type: "items", | |
| component: "accordion", | |
| items: { | |
| dimensions: { | |
| uses: 'dimensions', | |
| min: 1, | |
| max: 1 | |
| }, | |
| measures: { | |
| uses: "measures", | |
| min: 1, | |
| max: 1 | |
| } | |
| } | |
| }, | |
| prePaint: function(layout) { | |
| var columns = layout.secondcube.qHyperCube.qSize.qcx; | |
| var totalheight = layout.secondcube.qHyperCube.qSize.qcy; | |
| var pageheight = Math.floor(10000 / columns); | |
| var numberOfPages = Math.ceil(totalheight / pageheight); | |
| var pages = Array.apply(null, Array(numberOfPages)).map(function(data, index) { | |
| var msg = { | |
| "method":"GetHyperCubeData", | |
| "handle":this.backendApi.model.handle, | |
| "params":["/secondcube/qHyperCubeDef", | |
| [{ | |
| qTop: (pageheight * index) + index, | |
| qLeft: 0, | |
| qWidth: columns, | |
| qHeight: pageheight | |
| }] | |
| ], | |
| "jsonrpc":"2.0" | |
| } | |
| return this.backendApi.model.session.rpc(msg).then(function(d) { return d.result; }); | |
| }, this); | |
| var Promise = qv.getService('$q'); | |
| Promise.all(pages).then(function(data) { | |
| var data = data.reduce(function(a,b) { return a.concat(b.qDataPages[0].qMatrix); },[]) | |
| this.$scope.ext.paint.call(this, this.$element, layout, data); | |
| }.bind(this)) | |
| }, | |
| paint: function (element, layout, data) { | |
| if (!data) return; | |
| } | |
| }; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this.backendApi.model.session.rpc is no longer supported. Do you have an alternate "hacky method" for paging data in Qlik Sense November 2017?