Pre-Selecting a Category in QlikView AccessPoint (QlikTip #52)

This article demonstrates a custom solution how to pre-select a category in QlikView AccessPoint. The pre-selected category will be opened by default, but the user still has the possibility to change the category by using the category select box (which is the default behavior of QlikView AccessPoint).

Setup

Follow these steps to customize your QlikView AccessPoint:

  1. Make a backup of the index.htm (which can be found at C:\Program Files\QlikView\Web)
  2. Add the below posted code to the header of the index.htm (after the jQuery include) and before the end of the html head tag
  3. Save the index.htm
<!-- Begin of customization for pre selecting categories in AccessPoint -->
<script type="text/javascript">
$(function () {

var cSelectedCategory = 'SelectedCategory';

function preSelectCategory() {
	var selectedCategory = unescape(getQueryString(cSelectedCategory));
	if (selectedCategory) {
		selectedCategory = (selectedCategory == 'All') ? '' : selectedCategory;
		//console.log("PreSelect Category based on QueryString: " + selectedCategory)
		$('#Category').val(selectedCategory).trigger('change');
	}
}

// copied from: http://stackoverflow.com/questions/3788125/jquery-querystring
function getQueryString(key) {
	var re = new RegExp('(?:\\?|&)' + key + '=(.*?)(?=&|$)', 'gi');
	var r = [], m;
	while ((m = re.exec(document.location.search)) != null) r.push(m[1]);
	return r;
}

// Calls
setTimeout(preSelectCategory, 100);
//console.log(ap);

});
</script>
<!-- End of customization for pre selecting categories in AccessPoint -->

Usage

Now you can passed the category which should be pre-selected via the QueryString:

Example for pre-selecting the category “Sales”:
http://localhost/qlikview/index.htm?SelectedCategory=Sales

Another example for pre-selecting the category “Sales Applications”:
http://localhost/qlikview/index.htm?Sales%20Applications

Note: %20 is the encoded character for a white space

Compatibility

I have tested this solution for the following browsers:

  • Chrome 27
  • Firefox 21
  • Internet Explorer 8, 9, 10
… and the following QlikView version:
  • QlikView 11
  • QlikView 11.2

Support

This solution is certainly not supported, after every QlikView Update or Service Release you will have to modify the index.htm again.
Bookmark and Share

and tagged , . Bookmark the permalink. Both comments and trackbacks are currently closed.

2 Comments

  1. Saravana Prabhu
    Posted August 6, 2013 at 00:20 | Permalink

    Hi Stefan,
    Will it work on QV10 SR 2?

    I tried but no luck.

    Thanks & Regards,
    Saravana Prabhu

    • Posted November 19, 2013 at 01:49 | Permalink

      Hi Saravana,

      sorry, just tested the solution with QlikView 11/QlikView 11.2 …

      Regards
      Stefan