Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Lavysh
Contributor
Contributor

Read data with pagination in GetObject callback

Hi all,

I'm trying to read data from object via Document.GetObject API, but I've got some issues:

  1. When I use desktop version of QlikView everything fine, I read 40k rows of data in tablebox in 90 seconds, but when I run the same script with the same amount of data in Web version of QlikView in IE it crashes with message "This page  stop respond..."

  2. When I'm trying to read by chunks I use PageObject (forum) method:

 

_this.Doc.GetObject(name, function () {
    this.Data.Page = new this.Data.PageObject(this.Data, 100, 1)
    this.Data.Page.Next()

    log('Page.Next(): ', this.Data.Page.Count, this.Data.Page.Current)

    this.Data.Page.Next()
    this.Data.Page.Next()
    this.Data.Page.Next()
    this.Data.Page.Next()

    var item = this.Data.Page.StartItem()
    log('Page.Next() x 4: ' , this.Data.Page.Count
                            , this.Data.Page.Current
                            , item
                            , this.Data.Rows.length)​

 

As a result output in console via QvConsole extension:

 

> Page.Next(): 21 2
> Page.Next() x 4: 21 6 500 40

So Page.Next() call changes page meta data like Page.Current, but does not change this.Data.Rows, however in JS API Documentation we can see:
Index to start reading data from in order to display data for the current page

Example:
var item = this.Data.Page.StartItem();
var text = this.Data.Rows[item][1].text​

 

We had got 500 as a result of StartIndex() call, when there is only 40 rows in data...
So my question is how can I read page data in GetObject callback?

  • GetObject call is a subscription on object changes - is there any way to unsubscribe?
1 Reply
Lavysh
Contributor
Contributor
Author

For the last question about how to unsubscribe from object updates I find only two methods:

  1. Closure variable

 

function getData(name) {
    var done = false

    _this.Doc.GetObject(name, function () {
        if (done) return

        // Some logic on Object data

        done = true
    })
}
​

 

  • Hack with private, undocumented this.callbackFn

 

function getData(name) {
    _this.Doc.GetObject(name, function () {
        // Some logic on Object data

        this.callbackFn = function() {}
    })
}
​

 

Is it only available options to do unsubscribe? They both seems to be not so obvious and clean.