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
|
|
|
|
2015-01-23 13:09:30 +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
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'htk-column'
|
|
|
|
,Properties:
|
|
|
|
{
|
2022-05-28 15:49:46 +00:00
|
|
|
value: {
|
2015-07-03 05:49:45 +00:00
|
|
|
type: String
|
2015-01-23 13:09:30 +00:00
|
|
|
,value: null
|
|
|
|
},
|
2022-05-28 15:49:46 +00:00
|
|
|
column: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
},
|
2022-05-28 15:49:46 +00:00
|
|
|
columnIndex: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: Number
|
|
|
|
,value: -1
|
|
|
|
},
|
2022-05-28 15:49:46 +00:00
|
|
|
title: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: String
|
|
|
|
,value: null
|
|
|
|
},
|
2022-05-28 15:49:46 +00:00
|
|
|
editable: {
|
2015-01-23 13:09:30 +00:00
|
|
|
type: Boolean
|
|
|
|
,value: false
|
|
|
|
},
|
2022-05-28 15:49:46 +00:00
|
|
|
renderer: {
|
2015-01-23 13:09:30 +00:00
|
|
|
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) {
|
2015-11-26 12:30:04 +00:00
|
|
|
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() {
|
2015-11-26 12:30:04 +00:00
|
|
|
return this._userCssClass;
|
2015-08-17 18:02:14 +00:00
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
,_cssClass: null
|
|
|
|
,_userCssClass: null
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes the column.
|
2022-05-26 06:08:31 +00:00
|
|
|
*/
|
|
|
|
,initialize: function(props) {
|
|
|
|
this.parent(props);
|
|
|
|
this.td = this.createElement('td');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-11-26 12:30:04 +00:00
|
|
|
|
2022-05-26 06:08:31 +00:00
|
|
|
,renderHeader: function() {
|
|
|
|
var th = this.createElement('th');
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
if (this.title)
|
2022-05-26 06:08:31 +00:00
|
|
|
th.appendChild(this.createTextNode(this.title));
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
return th;
|
|
|
|
}
|
2015-01-23 13:09:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2015-08-27 14:04:34 +00:00
|
|
|
|
2015-11-26 12:30:04 +00:00
|
|
|
if (this._cssClass)
|
|
|
|
td.className = this._cssClass;
|
2015-08-17 18:02:14 +00:00
|
|
|
|
|
|
|
return td;
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 15:49:46 +00:00
|
|
|
,updateColumnName: function(model) {
|
|
|
|
if (this.columnIndex !== -1)
|
|
|
|
this.column = model.getColumnName(this.columnIndex);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
|
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);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|