hedera-web/js/htk/column/index.js

96 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-10-16 14:16:08 +00:00
2022-06-06 08:53:59 +00:00
var NodeBuilder = require('../../vn/node-builder');
2016-10-16 14:16:08 +00:00
/**
* Represents a grid column. This is an abstract class and should not be
* instantiated directly.
2022-05-26 06:08:31 +00:00
*/
2022-05-28 15:49:46 +00:00
module.exports = new Class({
2016-10-16 14:16:08 +00:00
Extends: NodeBuilder
,Tag: 'htk-column'
2022-06-06 16:02:17 +00:00
,Properties: {
2022-05-28 15:49:46 +00:00
value: {
2015-07-03 05:49:45 +00:00
type: String
,value: null
},
2022-05-28 15:49:46 +00:00
column: {
type: String
,value: null
},
2022-05-28 15:49:46 +00:00
columnIndex: {
type: Number
,value: -1
},
2022-05-28 15:49:46 +00:00
title: {
type: String
,value: null
},
2022-05-28 15:49:46 +00:00
editable: {
type: Boolean
,value: false
},
2022-05-28 15:49:46 +00:00
renderer: {
type: Function
,value: false
},
2022-05-28 15:49:46 +00:00
class: {
2015-08-17 18:02:14 +00:00
type: String
2022-05-26 06:08:31 +00:00
,set: function(x) {
this._userCssClass = x;
if (this._cssClass)
this._cssClass = x +' '+ this._cssClass;
else
this._cssClass = x;
2015-08-17 18:02:14 +00:00
}
2022-05-26 06:08:31 +00:00
,get: function() {
return this._userCssClass;
2015-08-17 18:02:14 +00:00
}
}
}
,_cssClass: null
,_userCssClass: null
/**
* Initializes the column.
2022-05-26 06:08:31 +00:00
*/
,initialize: function(props) {
2022-06-06 16:02:17 +00:00
NodeBuilder.prototype.initialize.call(this, props);
2022-05-26 06:08:31 +00:00
this.td = this.createElement('td');
}
2022-05-26 06:08:31 +00:00
,renderHeader: function() {
var th = this.createElement('th');
if (this.title)
2022-05-26 06:08:31 +00:00
th.appendChild(this.createTextNode(this.title));
return th;
}
/**
* Draws the cell and returns its associated td.
*
* @return {HTMLTableData} the rendered cell
2022-05-26 06:08:31 +00:00
*/
,render: function() {
var td = this.td.cloneNode(true);
if (this._cssClass)
td.className = this._cssClass;
2015-08-17 18:02:14 +00:00
return td;
}
2022-05-28 15:49:46 +00:00
,updateColumnName: function(model) {
if (this.columnIndex !== -1)
this.column = model.getColumnName(this.columnIndex);
}
2022-05-26 06:08:31 +00:00
,changed: function(tr, newValue) {
2022-05-30 01:30:33 +00:00
this.emit('changed', tr.rowIndex - 1, newValue);
}
});