registerExtension method

STABLE.
This API is reliable and breaking changes are unlikely.

qlik.registerExtension(id, impl, metadata)

Registers an extension for use in this mashup. The extension is not installed on the Qlik Sense server and only available in the session where it is created.

As long as a JavaScript module is created in the correct format, it can be sent to the registerExtension function.

Version history

Introduced 2.2

Parameters

Name Type Description
id String Set the ID of the visualization extension.
impl Object

Set the extension implementation.

metadata Object

Optional. Extension meta-data, same format as the QEXT file.

Default: {"type":"visualization"}

Anatomy of the QEXT file

Examples

Example: Hello world on the fly

//define the helloworld extension
var helloworld = {

		paint: function ($element) {
			$element.html( "Hello world!!" );
		}
		
}
//register the extension
qlik.registerExtension( 'helloworld', helloworld );
 
var app = qlik.openApp( 'Helpdesk Management.qvf', config );
//create and show an object using the extension
app.visualization.create( 'helloworld', ["Case Owner Group"] ).then( function ( helloworld ) {
    helloworld.show( "QV00" );
} );

Example: Button row extension on the fly

//define the buttonrow extension
var buttonrow = {
	//define a ListObject
	initialProperties: {
		qListObjectDef: {
			qShowAlternatives: true,
			qFrequencyMode: "V",
			qSortCriterias: {
				qSortByState: 1
			},
			qInitialDataFetch: [{
				qWidth: 2,
				qHeight: 50
			}]
		}
	},
	//render
	paint: function ( $element, layout ) {
		var str = "",
			me = this;
		if ( !me.fld ) {
			me.fld = app.field( layout.qListObject.qDimensionInfo.qGroupFieldDefs[0] );
		}
		layout.qListObject.qDataPages[0].qMatrix.forEach( function ( row ) {
			str += format( '<button type="button" class="btn btn-{0}" data-value="{1}">{2}</button>',
				getClassForState( row[0].qState ), row[0].qElemNumber, row[0].qText );
		} );
		$element.html( str ).find( '.btn' ).on( 'click', function () {
			me.fld.select( [$( this ).data( 'value' )], true, true );
		} );
	}
}
//register the extension
qlik.registerExtension( 'buttonrow', buttonrow );
 
var app = qlik.openApp( 'Helpdesk Management.qvf', config );
//create and show an object using the extension
app.visualization.create( 'buttonrow', ["Case Owner Group"] ).then( function ( topbuttonrow ) {
	topbuttonrow.show( "QV00" );
} );

Did this information help you?

Can you tell us why it did not help you and how we can improve it?

Thanks for helping us improve!