Getting Started | Class Index

Classes


Class Qv.Document

The QlikView Document object

Class Summary
Constructor Attributes Constructor Name and Description
 
Data for the document
Method Summary
Method Attributes Method Name and Description
 
AddBookmarkPaint(bookMarksSubscriber)
A collection of objects which want to know when the BookMarks change.
 
Back()
Previous selection
 
The bookmarks object.
 
Clear selections
 
Close the QlikView server session
 
Next selection
 
GetAllObjects(callbackFn({Array}))
The supplied callbackFn will be called with the objects, as an array, as parameter
 
GetAllVariables(callbackFn(object[]))
Provides access to the document variables.
 
GetCurrentSelections(currentSelectionOptions)
Get current selections and optionally rows for supplied fields.
 
GetObject(objectName)
This function appends the supplied callbackFn to an object when it's updated (e.g.
 
Lock selections
 
Redo()
Redo a previously undone operation.
 
SetBackgroundPaint(backgroundpaintFn)
Set a function to use for painting the Background.
 
SetOnUpdateComplete(onupdatecomplete)
Set a function to be called when all QlikView objects in a document are updated
 
SetTabrowPaint(tabrowpaintFn)
Set a function to use for painting the tabrow.
 
SetToolbarPaint(toolbarpaintFn)
Set a function to use for painting the Toolbar.
 
SetVariable(name, name)
Set a variable.
 
Undo()
Undo an undoable operation.
 
Unlock selections
Class Detail
Qv.Document
Data for the document
Method Detail
{void} AddBookmarkPaint(bookMarksSubscriber)
A collection of objects which want to know when the BookMarks change. Each object must have a .Paint function which will be called by QlikView when the bookmarks change. See Qv.Document.Bookmarks for more information on book marks.
Init = function() {

    var myDoc = Qv.GetCurrentDocument();

    var obj = {};
            
    obj.Paint = function() {
        var myBookmarks = myDoc.Bookmarks().BookMarks;
        var mySelect = document.getElementById("bmks");
        mySelect.options.length = myBookmarks.length;
        
        for (var i = 0; i < myBookmarks.length; i++) 
        {
            var option = mySelect.options[i];
            option.text = myBookmarks[i].text;
            option.value = myBookmarks[i].value;
        }
    }


    MyDoc.AddBookmarkPaint(obj);
}

Qv.InitWorkBench(
    { 
        View: 'FilmsWebView', 
        BodyOnLoadFunctionNames: ['Init'] 
    });
Parameters:
{Object} bookMarksSubscriber
An object with a function named Paint.

{void} Back()
Previous selection
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.Back(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{Qv.Document.Bookmarks} Bookmarks()
The bookmarks object.

{void} Clear()
Clear selections
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.Clear(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} CloseSession()
Close the QlikView server session
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.CloseSession(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} Forward()
Next selection
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.Forward(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} GetAllObjects(callbackFn({Array}))
The supplied callbackFn will be called with the objects, as an array, as parameter
Example:
    
GetObjectList = function() {

    var doc = Qv.GetDocument("Films");

    doc.GetAllObjects(function(objects) {

            for (var i = 0; i < objects.length; i++) 
            {
                
                var obj = objects[i];
                    
                var id = obj.id;
                var caption = obj.caption;
                var type = obj.type;
                var my = obj.my;
            }
        }
});
Parameters:
{Function} callbackFn({Array})
Your function which will be passed an array of objects.

{void} GetAllVariables(callbackFn(object[]))
Provides access to the document variables.
Example:
Init = function() {

    var mydoc = Qv.GetCurrentDocument();

    mydoc.GetAllVariables(function(vars) {

        for (var i = 0; i < vars.length; i++) {

            var obj = vars[i];

            var isConfig = obj.isconfig;
            var isNum = obj.isnum;
            var isReserved = obj.isreserved;
            var name = obj.name;
            var text = obj.text;
            var value = obj.value;
        }
    });
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
Parameters:
{Function} callbackFn(object[])
Your function which will be called with an array of variables in the data parameter

{void} GetCurrentSelections(currentSelectionOptions)
Get current selections and optionally rows for supplied fields.
Example:
//get all selected rows in fields Actor and Title when a selection is made
var mydoc = Qv.GetDocument("Films");

var fieldOptions1 = { "name": "Actor" };
var fieldOptions2 = { "name": "Title" };

var currentSelectionOptions =
    {
        onChange: function() {

            $('#currentSelections').empty();

            var data = this.Data.Rows;

            for (var f = 0; f < data.length; f++) {

                var field = data[f];
                var name = field[0].text;
                var vals = field[2].text;

                $('#currentSelections').append(name + ":" + vals);
            }
        },
        fields: [fieldOptions1, fieldOptions2]
    };

mydoc.GetCurrentSelections(currentSelectionOptions);
Parameters:
{Qv.CurrentSelectionOptions} currentSelectionOptions
The current selections object Qv.CurrentSelectionOptions

{Qv.Document.Object} GetObject(objectName)
This function appends the supplied callbackFn to an object when it's updated (e.g. moved, resized, new data from server etc). callbackFn is called with the original callee as a parameter.
Example:
var myFunc = function(myself) {
// this = the object you wanted to aquire.
// myself = your extension, the original "this".
};
    
var myObj = this.GetObject("Server\\LB02");
Parameters:
{String} objectName
The name of the object you want to append your callbackFn to.
Returns:
{Qv.Document.Object} Reference to the object.

{void} LockSelections()
Lock selections
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.LockSelections(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} Redo()
Redo a previously undone operation.
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.Redo(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} SetBackgroundPaint(backgroundpaintFn)
Set a function to use for painting the Background.
Example:
function myPainter() {

    //
    //  The element is the element you want to paint the background on.
    //
    var element = this.Element;
    element.style.backgroundColor = "red";
}

Init = function() {

    var mydoc = Qv.GetCurrentDocument();

    mydoc.SetBackgroundPaint(myPainter);
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
Parameters:
{Function} backgroundpaintFn

{void} SetOnUpdateComplete(onupdatecomplete)
Set a function to be called when all QlikView objects in a document are updated
Example:
var doc = Qv.GetDocument("Films");
doc.SetOnUpdateComplete(function() {alert("on update complete called");});
Parameters:
{Function} onupdatecomplete
The function to be called

{void} SetTabrowPaint(tabrowpaintFn)
Set a function to use for painting the tabrow.
 
Example:
var myPainter = function() {
    
    var element = this.Element;
    
    if (this.Layout.visible) {
        element.innerHTML = "Tabs go here"; 
    }
}

function Init() {

    var mydoc = Qv.GetCurrentDocument();

    mydoc.SetTabrowPaint(myPainter);
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
Parameters:
{Function} tabrowpaintFn

{void} SetToolbarPaint(toolbarpaintFn)
Set a function to use for painting the Toolbar.
Example:
var myPainter = function() {
    
    var element = this.Element;
    
    if (this.Layout.visible) {
        element.innerHTML = "Toolbar goes here"; 
    }
}

function Init() {

    var mydoc = Qv.GetCurrentDocument();

    mydoc.SetToolbarPaint(myPainter);
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
Parameters:
{Function} toolbarpaintFn

{void} SetVariable(name, name)
Set a variable.
Example:
var doc = Qv.GetDocument("Films");
doc.SetVariable("Var2","test");
Parameters:
{String} name
The name of the variable to set
{String} name
The new value for the variable

{void} Undo()
Undo an undoable operation. Typically these will be changes to layout, properties etc. and will not be related to selection state.
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.Undo(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });

{void} UnlockSelections()
Unlock selections
Example:
function Init() 
{
    var mydoc = Qv.GetCurrentDocument();

    document.getElementById("back").onclick = function() { myDoc.UnlockSelections(); };
}

Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });