Skip to main content

table.view

TableView : d2/sdk/controls/table/table.view

A Marionette.view to render Backbone.Collection data in tabular format.

Extends: Marionette.CollectionView

TableView~TableView

Kind: inner class of TableView
Prams: TableColumnCollection options.thumbnailColumns] - Columns used while rendering items as thumbnails. Can be kept as same as tableColumns.

new TableView(options)

ParamTypeDescription
optionsobject

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

options.tableColumnsTableColumnCollection

Column definition. Each model must have ColumnModel attrutes.

options.columnsTableColumnCollection

Server side columns. Can be kept as same as tableColumns.

options.connectorConnector

The connector instance.

options.collectionNodeCollection

The collection holding data for the table.

options.columnsWithSearchArray.<string>

Which columns should have search enabled on them.

options.originatingViewMarionette.View

Reference to a parent view where this table is hosted.

options.selectedChildrenNodeCollection

Collection to hold list of items selected.

options.inlineBarToolitemsFactory

Toolbar configuration for this table items.

options.selectRowsstring

Row selection model. Set to 'none'.

options.enableSortingboolean

Enable column sorting

[options.customLabels]object

Customized state messages as follows

[options.customLabels.emptySearchTable]string

Shown when search in the table returns no result.

[options.customLabels.zeroRecords]string

Shown when the underlying collection has no items in it.

TableView~TableColumnCollection : Backbone.Collection

Kind: inner typedef of TableView
Note: Each TableColumnCollection must implement a method getColumnKeys() that returns the key attribute values from each of it's models
Note: The model used for TableColumnCollection must use key as the idAttribute.
Example

define([
'nuc/lib/backbone'
], function(Backbone){
'use strict';

var TableModel = Backbone.Model.extend({
idAttribute: "key",
defaults: {
key: null,
sequence: 0
}
});

var TableColumnCollection = Backbone.Collection.extend({
model: TableColumnModel,
comparator: 'sequence',
getColumnKeys: function () {
return this.pluck('key');
}
});

//Then finally an instance might look like
var columnCollection = new TableColumnCollection([
{
key: 'attr1',
column_key: 'attr1',
sequence: 2, // Data column sequence should always start from 2, by design position 1 is reserved for displaying a selection checkbox.
definitions_order: 2,
sort: false,
title: 'Cell 1',
type: -1, //string data
permanentColumn: true, //Don't wrap if screen size reduces
isNaming: true
},
{
key: 'attr2',
column_key: 'attr2',
sequence: 3,
definitions_order: 3,
sort: false,
title: 'Cell 2',
type: -1,
permanentColumn: true,
isNaming: true
}
]);

return columnCollection;
});

TableView~ColumnModel : Object

Kind: inner typedef of TableView
Properties

NameTypeDescription
keystring

Data attribute name

column_keystring

Column identifier. Usually kept similar to key above.

sequencenumber

Order of this model in the associated column collection

definitions_ordernumber

Visible order of this column. Usually kept same as sequence above.

sortboolean

Enable sorting on this column

titlestring

Text to be displayed for this column

typenumber

data type associated with this column. See TableCellRegistry.

widthFactornumber

A decimal number to control this column's visual width in percentage.

permanentColumnboolean

Whether this is a permanent column. Permanent columns are not wrapped if screen size reduces.

isNamingboolean

Whether this is the naming column. At least one column should be marked as naming column in a column collection. Naming column is where the table renders its inline actionbar, if configured any.