Tuesday, 5 April 2011
No printing in Ajax
If you have any type of printing enabled in QlikView, the QlikView Desktop and Plugin will render the printing and submit to the relevant printer. This also gives facility for Print Preview. This facility is not available in Ajax - a limitation of the thin client.
To have printing in Ajax, any print jobs need to be rendered on the server into PDF and then presented to the user as a download.
The problem occurs if the IT department has "hardened" your QlikView Server. One of the common steps in hardening is to disable the Print Spooler Service. This is often built into a Group Policy rule also.
The problem for QlikView is that during installation of QlikView Server, the installer attempts to install the PDF XChange drivers. This step will fail if the Print Spooler service is not running.
Once you have sorted out the Print Spooler Service, you don't need to re-install QlikView Server. There is a PDF driver available as a separate download in the QlikView downloads area.
Monday, 4 April 2011
Beginners Guide to QlikView Extension Objects : Part 4 - Headers
Tuesday, 29 March 2011
Parameters in Dollar Expansion
Field2, $(mLefty(Field2)) as Field2.Code, $(mRighty(Field2)) as Field2.Desc,
Field3, $(mLefty(Field3)) as Field3.Code, $(mRighty(Field3)) as Field3.Desc,
Field4, $(mLefty(Field4)) as Field4.Code, $(mRighty(Field4)) as Field4.Desc,
Field5, $(mLefty(Field5)) as Field5.Code, $(mRighty(Field5)) as Field5.Desc,
Sunday, 9 January 2011
Beginners Guide to QlikView Extension Objects : Part 3
So, we have created custom extensions that display data from QlikView. However, we need to make that object respond to clicks and make selections back in the QlikView document.
This is achieved using the SelectRow function of the Data object. When we write out our data, we need to make sure that we keep track of what row that data came from so that we can execute an “onclick” function to call SelectRow with that row number. QlikView will then make that selection and refresh the data.
Here is the adjusted code to handle this:
Qva.AddExtension('CVL/BasicTable', function() {
// Create a variable to hold generated html
var html = "<table>";
// Local variable to hold the reference to QlikView
var _this = this;
// function to handle users clicking on a row
window.oncvlrowclick = function(rowIx)
{
_this.Data.SelectRow(rowIx);
}
// Cycle Through the data
for (var i = 0; i < this.Data.Rows.length; i++) {
// get the row
var row = this.Data.Rows [i];
// Generate html
html += "<tr><td onclick='oncvlrowclick("+i+")'>" + row[0].text + "</td><td onclick='oncvlrowclick("+i+")'>" + row[1].text + "</td></tr>";
}
// Finalise the html
html += "</table>";
// Set the HTML
this.Element.innerHTML = html;
},true);
OK, that is it. Time for you to take over and start creating your own objects. You now have the tools to create an object, populate it with QlikView data, and make it respond to clicks.
Enjoy.
Beginners Guide to QlikView Extension Objects : Part 2
In the last part, I showed how to create a really basic extension object. Now, I will build on that to use data from my QlikView application.
I am going to add a sub-folder to my CVL folder called “BasicTable” (so, CVL\BasicTable will be the sub-folder).
I need a definition.xml, icon.png and script.js. The quickest way to build these is to copy them from the previous project and then modify.
The initial contents of my definition will be:
<?xml version="1.0" encoding="utf-8"?>
<ExtensionObject Label="CVL Basic Table" />
Now, we can concentrate on the JavaScript to generate the output.
The QlikView object holder (which we can access via “this” in our JavaScript) defines an object called “Data” which will define the data passed by the object from the QlikView document. The data passed will depend on the Dimensions and Expressions defined in the properties of the object.
The Data object has a Rows property. Each Row in Rows is an array of values. The index corresponds to the number of Dimensions and Expressions. In a simple example, with one Dimension and one Expression, there will be 2 values in the array – 0 and 1. In multi-dimensional or multi-expression objects, the Dimensions will be the first values in the array, followed by the Expressions.
Lets define some code to cycle through the data and present it in a simple html table.
Qva.AddExtension('CVL/BasicTable', function() {
// Create a variable to hold generated html
var html = "<table>";
// Cycle Through the data
for (var i = 0; i < this.Data.Rows.length; i++) {
// get the row
var row = this.Data.Rows [i];
// Generate html
html += "<tr><td>" + row[0].text + "</td><td>" + row[1].text + "</td></tr>";
}
// Finalise the html
html += "</table>";
// Set the HTML
this.Element.innerHTML = html;
},true);
Now, if you add this object to a document, you won’t see anything. This is because we need to specify the Dimension and Expression first before any data will become available.
It is possible to define a default, of sorts, for Dimension and Expression. You could define an actual name or expression but, not every document might have that name and this could cause problems. If we set a blank default for Dimension and Expression, then QlikView will pick the first dimension and the sum of the first number value in the document as defaults. This gives something to show when the object adds (which might cause other problems!). To do this, we modify the definition.xml file. I am also going to define a default caption here:
<?xml version="1.0" encoding="utf-8"?>
<ExtensionObject Label="CVL Basic Table">
<Dimension Initial="" />
<Measurement Initial="" />
<Initiate Name="Caption.Text" value="CVL Basic Table" />
</ExtensionObject>
By the way, if you do make changes to the definition.xml or script.js files, it is not necessary to close and reopen QlikView to see those changes. Simply press F5 and QlikView will refresh. This is very useful in debugging.
Speaking of debugging, I’m afraid that the best way I have found to debug these JavaScript files is to add alert statements.
In the next part, I will show how to add code to handle when a user clicks in your custom object that will make a selection in your QlikView document.
Beginners Guide to QlikView Extension Objects : Part 1
I thought that I might write a quick guide to creating an extension objects for QlikView 10.
What is an extension object? Well, it allows us to create a chart using html and javascript or consume a 3rd party flash/silverlight object. Our chart can use data from QlikView and it can pass click events back to QlikView. Basically, we can create any chart that we want that doesn’t exist already.
You might think that there would be a whole lot of work to do to create this, but it is actually really simple to get a chart up and running and consuming QlikView data.
Extension objects live in the C:\Users\your.username\AppData\Local\QlikTech\QlikView\Extensions\Objects folder for desktop users. Each extension must have a folder for itself. However, you can have multiple sub-folder levels if you want.
The first thing that I will do in the Objects folder is create a sub-folder for my company’s extensions. My company is Capricorn Ventis Ltd. so I will create a folder called CVL. In this folder, I will create a sub-folder for each extension. First one that I am going to create is HelloWorld (doesn’t every example have to start with a Hello World!). Now, under the Objects folder, I have CVL\HelloWorld.
Every extension has a minimum of 1 file associated with it - Definition.xml. This file will define the element, ExtensionObject (which can have other sub elements to, for example, set some default values):
<?xml version="1.0" encoding="utf-8"?>
<ExtensionObject />
That’s it – simple. We will have a look at some additional options for this file in the next part.
With this one file in the HelloWorld folder, I can now see in QlikView (in Web View mode) when I right-click and select New Sheet Object, Extension Objects, I will see my new CVL/HelloWorld object (with no icon) which I can drag onto the sheet and it will create an object. It won’t be a very awe inspiring object (a blank box) but you can set properties (such as caption) just as you would for other charts.
We need to add a couple of things to make this just a little more advanced. First, if we want to have an icon (and you really should), we need to add a 24x24 PNG file called icon.PNG to the folder – any design that you want. Next, I am going to make a small modification to the Definition.xml file:
<?xml version="1.0" encoding="utf-8"?>
<ExtensionObject Label="CVL Hello World" />
This label will be what is displayed in the New Sheet Object dialog – next to the icon defined by the PNG file.
Now that those aesthetics are sorted out, we can make the object actually do something. We need to add a JavaScript file that will define the code that will be run by this object. The file is always called script.js. This js file must define a call to Qva.AddExtension which defines a name and function that will be called when the extension loads:
Qva.AddExtension('CVL/HelloWorld', function() {
// Set the HTML
this.Element.innerHTML = "<h1>Hello World</h1>";
},true);
Note that the name defined in AddExtension is the same as the path to the folder as it would be from the Objects folder. This is required.
This code is very simple – it just outputs some simple html – but it reveals how we can do some much more advanced stuff. If we can generate html, we can output it to our application and do so much! All we need now is some data.
In the next part, I will show you how to consume QlikView data.