Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If models or collections are required, they should be initialised here. By default, a widget extending Base widget (without visuals or logic) gets a initialized Squirro Item collection. Extending other widgets gets their respective collections.

 


afterInitialize()

widget.afterInitialize(/* no arguments */)    

Status
colourBlue
titleExtend

...

  • additionalQuery - specifies custom query part that will be added to the current dashboard query to produce the widget's query.
    • Allows presenting different datasets in different widgets
    • Note, produces more requests. Always take care to ensure the overall performance is not affected.
  • createdBefore - specifies an upper time restriction for the widget's collection fetch.
    • Supports both absolute (ISO format) dates and relative strings, e.g. '24h', '3months'
  • createdAfter - like createdBefore, but for lower time restriction


 

Expand
titleExample
Code Block
languagejs
titleExample
getCustomCollectionParams: function () {
	return {
		additionalQuery: 'Company:Squirro',
		createdBefore: '24h',
		createdAfter: '2011-01-01T00:00:00',
	};
},
 


Rendering

In this stage the widget content is rendered into its container. The container is managed by the Squirro Dashboard automatically. So after this stage the widget is fully in the page's DOM tree and displayed to the user.

...

Returns a hash of all the parameters that are passed into the custom template. The return value of this method is used as input for the customWidgetTemplate call.

...

customResources

widget.customTemplatescustomResources['myTemplate.html'](parameters)

...

Optional parameters can be passed in and accessed in the template.

...

widget.customScriptscustomResources['myLibrarymyStylesheet.jscss'](/* no arguments */)

If any additional (apart from widget.js) javascript files have been uploaded with the widget, they can be accessed trough this property.

Contains a dictionary with keys being the script file names, and values inline functions which, when called, will return the Promise resolving when the asynchronous loading of the script into global scope finishes.

Code Block
languagejs
widget.customScripts['myLibrary.js']().then(libraryResolvedFunction);

When loading multiple scripts, it is possible to chain the loading, like so (note, the scripts will be loaded synchronously).

...

languagejs

...

(apart from widget.css) CSS stylesheets have been uploaded with the widget, they can be accessed trough this property.

Contains a dictionary with keys being the template file names, and values the functions which will ensure the CSS is in the document for the lifecycle of the widget (and will be unloaded afterwards).

DISABLE_FULL_GRID

widget.DISABLE_FULL_GRID (default: false)

...

  • defaultValue
    • Specifies the default value the property should use (for example when widget has been freshly added to the dashboard and thus not configured yet).
    • Value type depending on the property type.
  • denyValidate
    • Allows to skip validation on fields. By default basic form validation is performed, depending on the property type.

 

...



Expand
titleExample
Code Block
languagejs
// Use the base (empty) property page and extend it with new fields
return Pages.Base.extend({
	customNormal: [
		{
			view: Properties.Number,
			config: {
				inputName: 'myNumber',
				infoText: 'Select a number from 3 to 7',
				min: 3,
				max: 7,
				defaultValue: 5,
			},
		},
	],
});

...