Qv

Examples
Example 1: Capture the event when a selection have been made in a listbox.    
var doc;
var lb;
qvInit = function () {
    doc = Qv.GetCurrentDocument();
    lb = doc.GetObject("LB36");
    lb.SetOnUpdateComplete(listboxUpdated);
}
listboxUpdated = function () {
    var selected = this.Data.GetSelected();
    //"selected" is now an array of objects
    alert(selected.length + " selected items");
    //loop through the array
    for (var i = 0; i < selected.length; i++) 
    {
        //get the "text" property
        var text = selected[i].text;
    }
}
Qv.InitWorkBench({ View: "Movies Database", BodyOnLoadFunctionNames: "qvInit" });
Example 2: Clear selections in a listbox. The function "clearSelection" must be called from your code.
var doc;
var lb;
qvInit = function () {
    doc = Qv.GetCurrentDocument();
    lb = doc.GetObject("LB36");
}
clearSelection = function () {
    lb.Data.ClearSelections();
}
Qv.InitWorkBench({ View: "Movies Database", BodyOnLoadFunctionNames: "qvInit" });

Classes

Config
CurrentSelectionOptions
CustomIcons
Document
FieldOptions

Methods

AddExtension(name, extensionPaint)

Function to call in the JavaScript for a QlikView extension to register the extension.
Parameters:
NameTypeDescription
nameStringName of the extension
extensionPaintfunctionPaint function for the extension
Example
The following would be, for example, for an extension contained in
C:\Users\[UserName]\AppData\Local\QlikTech\QlikView\Extensions\
Objects\MyCompanyName\MyExtensionName

The code below would be in a file named script.js contained in the above 
directory. Any associated JavaScript and css files would be contained alongside 
this file.

Note that the exact path above might vary depending on your Windows version and 
whether you are deploying the extension in QlikView server or QlikView desktop.

Example 1:
function paint()
{
    var htmlElement = this.Element;
    var data = this.Data.Rows;
    // Render extension here.
}

Qv.AddExtension("MyCompanyName\MyExtensionName", paint);

Example 2: This example illustrates how a css file for the extension could also 
be loaded.

function paint()
{
    var htmlElement = this.Element;
    var data = this.Data.Rows;
    // Render extension here.
}

Qv.AddExtension("MyCompanyName\MyExtensionName", paint);
Qva.LoadCSS(Qv.GetExtensionSrc("Extensions/MyCompanyName/MyExtensionName/MyStyles.css"));

GetAllDocuments(callbackFn(object[]))

The supplied callbackFn will be called with the documents, as an array of document objects, as parameter
Parameters:
NameTypeDescription
callbackFn(object[])functionYour function which will be called with an array of documents in the data parameter
Example
function init() {

    Qv.GetAllDocuments(function(docs) {
        // process array here.
    });

}

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

GetCurrentDocument() → {Qv.Document}

Returns a handle to the current QlikView document. Can be used from an extension to access Document data regardless of the document name.
Returns:
Reference to the object.
Type
Qv.Document
Example
var myDoc;

Init = function() {

    mydoc = Qv.GetCurrentDocument();

    // Work with document here.
}

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

GetDocument(document) → {Qv.Document}

Returns a handle to a QlikView Document with a specific document name.
Parameters:
NameTypeDescription
documentStringThe name of the QlikView document (without extension).
Returns:
Reference to the object.
Type
Qv.Document
Example
Init = function() {

    var doc = Qv.GetDocument("FilmsWebView");
    // Work with document here.
}

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

GetExtensionSrc(extFilePath, isDocExtopt)

Get path to extension files, like images
Parameters:
NameTypeAttributesDescription
extFilePathStringExtension file path
isDocExtBoolean <optional>
If the extension is a document extension
Example
var extPath = 'Extensions/MyCompanyName/MyExtensionName/';
    var img = document.createElement("IMG");
    img.src = Qv.GetExtensionSrc(extPath + 'myImg.png');

InitWorkBench(config)

Initialize workbench. If you need multiple documents you insert one function call to Qv.InitWorkBench for every document. NB! there can only be one value per page for the following parameters (QvAjaxZfcPath, BodyOnLoadFunctionNames, CSS ) so make sure you put them in the first call to Qv.InitWorkBench (if you want to set them). At a minimum you must supply the parameter View in the call.
Parameters:
NameTypeDescription
configQv.ConfigConfiguration data for the connection to a QlikView document
Examples
Qv.InitWorkBench({ View: 'Films' });
    
Qv.InitWorkBench({ View: 'Films', BodyOnLoadFunctionNames: ["MyInit", "MyInit2"], CustomIcons: {CA:"NewClearAll.bmp", CD:"NewClear.bmp"} });

LoadExtensionScripts(filesArray, callbackFn, isDocExtopt)

Load javascripts needed for QlikView extension object.
Parameters:
NameTypeAttributesDescription
filesArrayArray.<String>Array of javascripts
callbackFnfunctionFunction to be called when scripts are loaded
isDocExtBoolean <optional>
If it's script for a document extension
Example
function scriptsLoaded()
{
    alert('scriptsLoaded fired');
}

function loadScripts() {
    var files = [],
        extPath = 'Extensions/MyCompanyName/MyExtensionName/';
    
    files.push(extPath + 'myJSFile.js');
    Qv.LoadExtensionScripts(files, scriptsLoaded);
}