Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
Thanks to Erik for pointing out the limit for the initial data fetch when coding up an extension in Sense here:
http://community.qlik.com/message/596622#596622
The manual pages are almost cryptic about how the getData method works.
Could anyone give me any insights/examples as to how I might use it? I want to load all data, and then start painting my object
Thanks,
Justin
Hi,
some pseudo-code for this
paint: function ( $element ) { var lastrow = 0, me = this; //loop through the rows we have and render this.backendApi.eachDataRow( function ( rownum, row ) { lastrow = rownum; //do something with the row.. }); if(this.backendApi.getRowCount() > lastrow +1){ //we havent got all the rows yet, so get some more, 1000 rows var requestPage = [{ qTop: lastrow + 1, qLeft: 0, qWidth: 10, //should be # of columns qHeight: Math.min( 1000, this.backendApi.getRowCount() - lastrow ) }]; this.backendApi.getData( requestPage ).then( function ( dataPages ) { //when we get the result trigger paint again me.paint( $element ); } ); } } getData will get the cells defined by requestpage and return them in the parameter dataPages but also update the layout buffer used by eachDataRow, so when the paint function is called again it will have all rows. If you do like this the visualization will build up gradually. | |
Edit: corrected the code somewhat.
I agree it's not perfectly clear from the help, could use some more examples. The Table-Template example in the manual uses the function, maybe that can help you a bit.
Hi,
some pseudo-code for this
paint: function ( $element ) { var lastrow = 0, me = this; //loop through the rows we have and render this.backendApi.eachDataRow( function ( rownum, row ) { lastrow = rownum; //do something with the row.. }); if(this.backendApi.getRowCount() > lastrow +1){ //we havent got all the rows yet, so get some more, 1000 rows var requestPage = [{ qTop: lastrow + 1, qLeft: 0, qWidth: 10, //should be # of columns qHeight: Math.min( 1000, this.backendApi.getRowCount() - lastrow ) }]; this.backendApi.getData( requestPage ).then( function ( dataPages ) { //when we get the result trigger paint again me.paint( $element ); } ); } } getData will get the cells defined by requestpage and return them in the parameter dataPages but also update the layout buffer used by eachDataRow, so when the paint function is called again it will have all rows. If you do like this the visualization will build up gradually. | |
Edit: corrected the code somewhat.
That's great, thanks Erik.
I agree there's a great deal of sense in buffering and giving the users something to look at at the earliest possible moment. The problem here is I'm calculating a trellis for the incoming data, so can't calculate how I'm going to paint until I have all the data.
What might be useful is some kind of paging by category. In my javascript I'm using D3 to nest my data, If I could pull in my nested groups in one at a time that would be better than all at once. Any ideas about that?
Thanks
Justin
Hello Erik,
Can you please tell how we can achieve same result for hyperCube with Pivot mode enabled? It seems that eachDataRow function is not taking Pivot-shaped data into consideration.
Thanks in advance,
Adrian