Skip to main content

listitem.type.model.view

ListItemTypeModel : d2/sdk/controls/list/listitem.type.model.view

A list item view that can work with any Backbone.Model.

Extends: Marionette.ItemView
Example (Typical usage)

define([
'nuc/lib/backbone',
'nuc/lib/marionette',
'd2/sdk/controls/list/simple.list.view',
'd2/sdk/controls/list/listitem.type.model.view',
'd2/sdk/utils/contexts/context.utils',
], function(Backbone, Marionette, ListView, ListItemTypeModelView, contextUtils){
'use strict';

var collection = new Backbone.Collection([
{
id: 1,
name: 'One'
},
{
id: 2,
name: 'Two'
},
{
id: 3,
name: 'Three'
}
]), context = contextUtils.getPerspectiveContext();

var MyListView = ListView.extend({
childView: ListItemTypeModelView,
childViewOptions: function() {
var opts = _.extend({}, this.options);
opts.templateHelpers = function () {
return {
name: this.model.get('name'),
itemLabel: this.model.get('name'),
enableIcon: false,
showInlineActionBar: false
};
};
return opts;
},
constructor: function MyListView(options) {
options = options || {};
MyListView.__super__.constructor.call(this, options);
}
});

var myList = new MyListView({collection: collection, context: context});
new Marionette.Region({el: '.host-el'}).show(myList);
});

listItemTypeModel.templateHelpers() ⇒ TemplateOptions

Kind: instance method of ListItemTypeModel
Returns: TemplateOptions - That controls how each item is rendered.

ListItemTypeModel~ListItemTypeModel

Kind: inner class of ListItemTypeModel

new ListItemTypeModel(options)

ParamTypeDescription
optionsobject

Constructor options

[options.context]Context

Reference to the active application context. Needed only if the listitem is going to have a dropdown menu.

[options.toolbarData]object
[options.toolbarData.toolbaritems]ToolitemsFactory

Menu configuration

ListItemTypeModel~TemplateOptions : object

Kind: inner typedef of ListItemTypeModel

ParamTypeDefaultDescription
namestring

Displayable text for the item

itemLabelstring

Aria-label associated with the item

[enableIcon]Booleanfalse

Whether to show an icon for the item

[icon]string

CSS class name of an icon to be shown for the item. Ignored if enableIcon is set to false.

[showInlineActionBar]Booleanfalse

Whether the item will have a dropdown menu