table.view
TableView : d2/sdk/controls/table/table.view
A Marionette.view to render Backbone.Collection data in tabular format.
Extends: Marionette.CollectionView
- TableView :
d2/sdk/controls/table/table.view- ~TableView
- ~TableColumnCollection :
Backbone.Collection - ~ColumnModel :
Object
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)
| Param | Type | Description |
|---|---|---|
| options | object | Constructor options. Following are the options specifically supported by the list apart from those from its supertype. |
| options.tableColumns | TableColumnCollection | Column definition. Each model must have |
| options.columns | TableColumnCollection | Server side columns. Can be kept as same as |
| options.connector | Connector | The connector instance. |
| options.collection | NodeCollection | The collection holding data for the table. |
| options.columnsWithSearch | Array.<string> | Which columns should have search enabled on them. |
| options.originatingView | Marionette.View | Reference to a parent view where this table is hosted. |
| options.selectedChildren | NodeCollection | Collection to hold list of items selected. |
| options.inlineBar | ToolitemsFactory | Toolbar configuration for this table items. |
| options.selectRows | string | Row selection model. Set to 'none'. |
| options.enableSorting | boolean | 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
| Name | Type | Description |
|---|---|---|
| key | string | Data attribute name |
| column_key | string | Column identifier. Usually kept similar to |
| sequence | number | Order of this model in the associated column collection |
| definitions_order | number | Visible order of this column. Usually kept same as |
| sort | boolean | Enable sorting on this column |
| title | string | Text to be displayed for this column |
| type | number | data type associated with this column. See TableCellRegistry. |
| widthFactor | number | A decimal number to control this column's visual width in percentage. |
| permanentColumn | boolean | Whether this is a permanent column. Permanent columns are not wrapped if screen size reduces. |
| isNaming | boolean | 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. |