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.