Skip to main content Skip to complementary content

Toolbar

The Toolbar visualization extension demonstrates how to programatically call Qlik Sense functions. It also shows that you can create a visualization extension that does not visualize Qlik Sense data but is used for interaction with the app. You do this by leveraging the Mashup API into your extension by loading the qlik JavaScript module, the same module used when building mashups that include Qlik Sense objects and calls.

Below you see three ways of how the Toolbar example can be displayed in Qlik Sense.

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. Define properties.

    To be able to interact with the app we use a qlik JavaScript module, the same module used when building websites that includes Qlik Sense objects and calls:

    define(["jquery",
    //mashup and extension interface
    "qlik"], function($, qlik) {
    	function createBtn(cmd, text) {
    		return '<button class="qui-button" style="font-size:13px;" data-cmd="' + cmd + '">' + text + '</button>';
    	}
  3. Implement paint method.

    In the paint method we create the HTML for our extension based on data in the data parameter.

    Then we set the content of the $element parameter to display the extension content.

    		paint : function($element, layout) {
    			$element.css('overflow', 'auto');
    			//create the app button group
    			var html = '', app = qlik.currApp(this);
    			html += '<div class="qui-buttongroup">';
    			if(layout.buttons.clear) {
    				html += createBtn("clearAll", "Clear All");
    			}
    			if(layout.buttons.back) {
    				html += createBtn("back", "Back");
    			}
    			if(layout.buttons.forward) {
    				html += createBtn("forward", "Forward");
    			}
    			if(layout.buttons.lockall) {
    				html += createBtn("lockAll", "Lock All");
    			}
    			if(layout.buttons.unlockall) {
    				html += createBtn("unlockAll", "Unlock All");
    			}
    Information noteFor full implementation on the paint method, see the full code example.
  4. App level commands.

    The extension connects app level commands to a row of buttons:

    			$element.find('button').on('qv-activate', function() {
    				switch($(this).data('cmd')) {
    					case 'clearAll':
    						app.clearAll();
    						break;
    					case 'back':
    						app.back();
    						break;
    					case 'forward':
    						app.forward();
    						break;
    					case 'lockAll':
    						app.lockAll();
    						break;
    					case 'unlockAll':
    						app.unlockAll();
    						break;
  5. Field level commands.

    The Toolbar extension connects some field level commands to another row of buttons using the value selected in the drop-down list as the field name parameter:

    					//field actions
    					case 'clear':
    						app.field(layout.field.list ? $fields.val() : layout.field.fixed).clear();
    						break;
    					case 'lock':
    						app.field(layout.field.list ? $fields.val() : layout.field.fixed).lock();
    						break;
    					case 'unlock':
    						app.field(layout.field.list ? $fields.val() : layout.field.fixed).unlock();
    						break;
    					case 'selectmatch':
    						app.field(layout.field.list ? $fields.val() : layout.field.fixed).selectMatch($element.find("#match").val(), true);
    						break;
  6. Bookmark commands.

    Bookmark actions are connected to another row of buttons:

    					//bookmark actions
    					case 'bmapply':
    						app.bookmark.apply($bookmarks.val());
    						break;
    					case 'bmcreate':
    						app.bookmark.create($element.find("#bmtitle").val(), null);
    						break;

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!