Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
segador_
Partner - Contributor III
Partner - Contributor III

How to get all rows in QlikView object?

Hi, this question about qlikview extensions. I need to get all rows in QlikView object and write them into array "dataLine".

Here is my js-code:

var obj = doc.GetObject(objectName);

obj.callbackFn = function () {

            try

            {

                this.Data.Page = new this.Data.PageObject(this.Data, 100, 1);

               

                var pStart = this.Data.Page.StartItem();

                var pEnd = pStart + this.Data.Page._size;

                var oldpEnd = pEnd;

                for (var k = 1; k <= 50; k++) {

                    //alert("Page number:" + k);

                    for (var i = pStart; i < pEnd; i++) {

                        try

                        {

                            var dataLine = new Array();

                            for (var j = 0; j < this.Data.Rows.length; j++) {

                                var cell = {

                                    text: this.Data.Rows.text,

                                    value: this.Data.Rows.value,

                                    style: this.Data.Rows.color

                                };

                                dataLine.push(cell);

                            }

                            res.rows.push(dataLine);

                        }

                        catch(ex)

                        {

                           // alert("Error in data line " + ex.message + " Page number: " + k + " " + pStart + " " + pEnd + " " + i);

                        }

                    }

                    oldpEnd = pEnd;

                    this.Data.Page.Next();

                    pStart = this.Data.Page.StartItem();

                    pEnd = pStart + this.Data.Page._size;

                    if (pEnd == oldpEnd) {

                        //alert("Exit "  + pEnd);

                        break;

                    }

                }

            }

            catch(ex)

            {

                alert("Paging Error " + ex.message);

            }

}

I get an exception (in line 32) when I run this code and object has more than 40 lines. Despite the execution of the Next() method in the this array.Data.Rows no new rows beyond those that are limited by the size of the page. As workaround i can set bigger page size, but object need to recalculate.

Regards, Igor.
1 Reply
ThomasGorr
Partner - Contributor III
Partner - Contributor III

Hi Igor, on your first try you get 40 rows by default. If you want to get more rows, you need to set PageSizeY: https://help.qlik.com/en-US/qlikview-developer/November2017/apis/js+API/symbols/Qv.Document.Object.D... After you have set that, you will get the new dataset.