Skip to main content Skip to complementary content

Horizontal list

The Horizontal list example demonstrates a horizontal listbox. It demonstrates how to build a visualization extension based on a list object definition and it also demonstrates some different options in implementing selection support.

Finding the examples

  • Qlik Sense Desktop: ...\Users\<UserName>\Documents\Qlik\Examples\Extensions.

  • Qlik Sense: ...\ProgramData\Qlik\Examples\Extensions.

Full code example

Example breakdown

  1. Edit the applicable fields of the QEXT file to set a default title, description, icon and type.

  2. Use a list object definition. To do this, you set up your initial properties to include a qListObjectDef:

    	return {
    		initialProperties : {
    			version: 1.0,
    			qListObjectDef : {
    				qShowAlternatives : true,
    				qFrequencyMode : "V",
    				qInitialDataFetch : [{
    					qWidth : 2,
    					qHeight : 50
    				}]
    			},
    			fixed : true,
    			width : 25,
    			percent : true,
    			selectionMode : "CONFIRM"
    		},
  3. You also need to set up your properties panel to reference the qListObjectDef in definition:

    dimension : {
    	type : "items",
    	translation : "properties.dimension",
    	ref : "qListObjectDef",
  4. In your paint method you can use the helper method eachDataRow, which is available in the Backend API, to loop through your data. You can also render frequency if frequency is enabled:

    			this.backendApi.eachDataRow(function(rownum, row) {
    				html += '<li ' + style + ' class="data state' + row[0].qState + '" data-value="' + row[0].qElemNumber + '">' + row[0].qText;
    				if(row[0].qFrequency) {
    					html += '<span>' + row[0].qFrequency + '</span>';
    				}
    				html += '</li>';
    			});
  5. Enable selections. In an extension, you can choose between three options for selections.

    • No selections
    • Standard Qlik Sense selection model with toolbar and wrapper around the object
    • Quick selection, where selections are sent straight to the Qlik Sense Engine and immediately are reflected in the object

    For standard Qlik Sense selection mode, use the selectValues method available in the extension:

    	self.selectValues(dim, [value], true);

    For Quick selection, send selections straight to the Engine using the Backend API:

    	self.backendApi.selectValues(dim, [value], true);
  6. Enable snapshots for use in storytelling:

    snapshot : {
    	canTakeSnapshot : true
    },
  7. Add styling to separate CSS file.

    It is good programming practice to keep your styling in a separate CSS file. Qlik Sense set the CSS class qv-object-[extension name] on your extensions. You should prefix your CSS rules with that. You then load your CSS file with RequireJS and add its content to the HTML page:

    define(["jquery", "text!./horizlist.css"], function($, cssContent) {'use strict';
    	$("<style>").html(cssContent).appendTo("head");

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!