Skip to main content

simple.list.view

SimpleListView : d2/sdk/controls/list/simple.list.view

A flat list view backed by a Backbone.Collection.

Backbone.Model instances could be added/removed from the backing collection to update the view dynamically.

Extends: Marionette.CollectionView
See

Example (Sample list with a selection)

define([
'nuc/lib/backbone',
'nuc/lib/marionette',
'd2/sdk/controls/list/simple.list.view',
'd2/sdk/controls/list/listitem.type.node.view',
'd2/sdk/models/node.model'
], function(Backbone, Marionette, ListView, ListItemTypeNodeView, NodeModel){
'use strict';

var MyListView = ListView.extend({
childView: ListItemTypeNodeView,
constructor: function MyListView(options) {
options = options || {};
MyListView.__super__.constructor.call(this, options);
}
});

var MyCollection = Backbone.Collection.extend({
model: NodeModel
});

var collection = new MyCollection([
{id: '1', name: 'One', mime_type: 'application/pdf'},
{id: '2', name: 'Two', mime_type: 'image/jpg'}
]);

new Marionette.Region({el: '.host-el'}).show(new MyListView({
collection: collection, selectedModel: new NodeModel({id: '2'})
}));
});

simpleListView.mergeAttributesFromSelectedModelOnIDChange : Boolean

Whether to merge attributes of constructor option selectedModel to matching model within the collection whenever id attribute of the selectedModel changes.

Kind: instance property of SimpleListView
Default: true

simpleListView.skippableAttributesOnMerge : Array.<string>

Which attributes to skip while merging from selectedModel to a matching model within the collection

Kind: instance property of SimpleListView
Default: ['name']

simpleListView.attributesUsedForEqualityComparison : Array.<string>

Which attributes are used to compare for equality of selectedModel and models within the collection

Kind: instance property of SimpleListView
Default: ['id']

SimpleListView~SimpleListView

Kind: inner class of SimpleListView

new SimpleListView(options)

ParamTypeDescription
optionsobject

Constructor options. Following are the options specifically supported by the list apart from those from its supertype.

[options.emptyStateMessage]string

Message to show when there are no items in the associated collection.

[options.selectedModel]NodeModel

Show a selection highlight for this model