2016-10-16 14:16:08 +00:00
|
|
|
|
|
|
|
var NodeBuilder = require ('./node-builder');
|
|
|
|
|
2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* Represents a grid column. This is an abstract class and should not be
|
|
|
|
* instantiated directly.
|
|
|
|
**/
|
2016-09-26 09:28:47 +00:00
|
|
|
module.exports = new Class
|
2015-01-23 13:09:30 +00:00
|
|
|
({
|
2016-10-16 14:16:08 +00:00
|
|
|
Extends: NodeBuilder
|
2015-01-23 13:09:30 +00:00
|
|
|
,Tag: 'htk-column'
|
|
|
|
,Properties:
|
|
|
|
{
|
|
|
|
value:
|
|
|
|
{
|
2015-07-03 05:49:45 +00:00
|
|
|
type: String
|
2015-01-23 13:09:30 +00:00
|
|
|
,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
|
|
|
|
,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
|
|
|
}
|
|
|
|
,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.
|
|
|
|
**/
|
|
|
|
,initialize: function (props)
|
|
|
|
{
|
2015-11-09 08:14:33 +00:00
|
|
|
this.parent (props);
|
2016-10-16 14:16:08 +00:00
|
|
|
this.td = this.createElement ('td');
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
,renderHeader: function ()
|
|
|
|
{
|
2016-10-16 14:16:08 +00:00
|
|
|
var th = this.createElement ('th');
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
if (this.title)
|
2016-10-16 14:16:08 +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.
|
|
|
|
*
|
|
|
|
* @param {HTMLTableRow} tr the table row
|
|
|
|
* @return {HTMLTableData} the rendered cell
|
|
|
|
**/
|
|
|
|
,render: function (tr)
|
|
|
|
{
|
2015-08-17 18:02:14 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
,updateColumnIndex: function (model)
|
|
|
|
{
|
|
|
|
if (this.column)
|
|
|
|
this.columnIndex = model.getColumnIndex (this.column);
|
|
|
|
}
|
|
|
|
|
|
|
|
,changed: function (tr, newValue)
|
|
|
|
{
|
|
|
|
this.signalEmit ('changed', tr.rowIndex - 1, newValue);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|