Qv.Document
Classes
Methods
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.
Parameters:
Name | Type | Description |
---|---|---|
bookMarksSubscriber | Object | An object with a function named Paint. |
Example
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']
});
Back()
Previous selection
Example
function Init()
{
var mydoc = Qv.GetCurrentDocument();
document.getElementById("back").onclick = function() { myDoc.Back(); };
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
Bookmarks()
The bookmarks object.
Clear()
Clear selections
Example
function Init()
{
var mydoc = Qv.GetCurrentDocument();
document.getElementById("back").onclick = function() { myDoc.Clear(); };
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
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'] });
Forward()
Next selection
Example
function Init()
{
var mydoc = Qv.GetCurrentDocument();
document.getElementById("back").onclick = function() { myDoc.Forward(); };
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
GetAllObjects(callbackFn({Array}))
The supplied callbackFn will be called with the objects, as an array, as parameter
Parameters:
Name | Type | Description |
---|---|---|
callbackFn({Array}) | function | Your function which will be passed an array of objects. |
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;
}
}
});
GetAllVariables(callbackFn(object[]))
Provides access to the document variables.
NB! The text attribute of the variables will always be empty, since calculation of the expressions could overload the server.
Parameters:
Name | Type | Description |
---|---|---|
callbackFn(object[]) | function | Your function which will be called with an array of variables in the data parameter |
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 value = obj.value;
}
});
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
GetCurrentSelections(currentSelectionOptions)
Get current selections and optionally rows for supplied fields.
Parameters:
Name | Type | Description |
---|---|---|
currentSelectionOptions | Qv.CurrentSelectionOptions | The current selections object Qv.CurrentSelectionOptions |
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);
GetObject(objectName) → {Qv.Document.Object}
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.
Parameters:
Name | Type | Description |
---|---|---|
objectName | String | The name of the object you want to append your callbackFn to. |
Returns:
Reference to the object.
- Type
- Qv.Document.Object
Example
var myFunc = function(myself) {
// this = the object you wanted to aquire.
// myself = your extension, the original "this".
};
var myObj = this.GetObject("Server\\LB02");
LockSelections()
Lock selections
Example
function Init()
{
var mydoc = Qv.GetCurrentDocument();
document.getElementById("back").onclick = function() { myDoc.LockSelections(); };
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });
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'] });
SetBackgroundPaint(backgroundpaintFn)
Set a function to use for painting the Background.
Parameters:
Name | Type | Description |
---|---|---|
backgroundpaintFn | function |
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'] });
SetOnUpdateComplete(onupdatecomplete)
Set a function to be called when all QlikView objects in a document are updated
Parameters:
Name | Type | Description |
---|---|---|
onupdatecomplete | function | The function to be called |
Example
var doc = Qv.GetDocument("Films");
doc.SetOnUpdateComplete(function() {alert("on update complete called");});
SetTabrowPaint(tabrowpaintFn)
Set a function to use for painting the tabrow.
Parameters:
Name | Type | Description |
---|---|---|
tabrowpaintFn | function |
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'] });
SetToolbarPaint(toolbarpaintFn)
Set a function to use for painting the Toolbar.
Parameters:
Name | Type | Description |
---|---|---|
toolbarpaintFn | function |
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'] });
SetVariable(name, name)
Set a variable.
Parameters:
Name | Type | Description |
---|---|---|
name | String | The name of the variable to set |
name | String | The new value for the variable |
Example
var doc = Qv.GetDocument("Films");
doc.SetVariable("Var2","test");
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'] });
UnlockSelections()
Unlock selections
Example
function Init()
{
var mydoc = Qv.GetCurrentDocument();
document.getElementById("back").onclick = function() { myDoc.UnlockSelections(); };
}
Qv.InitWorkBench({ View: 'FilmsWebView', BodyOnLoadFunctionNames: ['Init'] });