Creating an interactive extension
This recipe follows on from the previous one to show how we add interactivity to our QlikView.
Getting ready
Create the extension from the Creating a simple HTML table recipe.
How to do it…
Follow these steps to create an interactive extension:
Edit the
Script.js
file. Modify therowstrin
g
value like this:var rowstring = "<tr><td class='myTable' onClick='onmyrowclick({2});'>{0}</td><td class='myTableR'>{1}</td></tr>";
Just below this line, add this new code block:
// Register a function to handle the click window.onmyrowclick = function(irow) { _this.Data.SelectRow(irow); }
Finally, modify the line that builds the HTML (under the
// Gener
ate HTML
comment):html += rowstring.format(row[0].text, addCommas(row[1].text), i);
Save the file and open the QlikView file. Note that if you have the QlikView file open, just pressing F5 will refresh the JavaScript.
Note what happens when you click a country name in the grid.