hedera-web/js/htk/column.js

105 lines
1.6 KiB
JavaScript
Raw Normal View History

2016-10-16 14:16:08 +00:00
2022-05-26 06:08:31 +00:00
var NodeBuilder = require('./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
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-10-16 14:16:08 +00:00
Extends: NodeBuilder
,Tag: 'htk-column'
,Properties:
{
value:
{
2015-07-03 05:49:45 +00:00
type: String
,value: null
},
column:
{
type: String
,value: null
},
columnIndex:
{
type: Number
,value: -1
},
title:
{
type: String
,value: null
},
editable:
{
type: Boolean
,value: false
},
renderer:
{
type: Function
,value: false
},
2015-08-17 18:02:14 +00:00
class:
{
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) {
this.parent(props);
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-26 06:08:31 +00:00
,updateColumnIndex: function(model) {
if (this.column)
2022-05-26 06:08:31 +00:00
this.columnIndex = model.getColumnIndex(this.column);
}
2022-05-26 06:08:31 +00:00
,changed: function(tr, newValue) {
this.signalEmit('changed', tr.rowIndex - 1, newValue);
}
});