2015-01-23 13:09:30 +00:00
|
|
|
/**
|
|
|
|
* Represents a grid column. This is an abstract class and should not be
|
|
|
|
* instantiated directly.
|
|
|
|
**/
|
|
|
|
Htk.Column = new Class
|
|
|
|
({
|
|
|
|
Extends: Vn.Object
|
|
|
|
,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)
|
|
|
|
{
|
|
|
|
this.td = document.createElement ('td');
|
2015-11-09 08:14:33 +00:00
|
|
|
this.parent (props);
|
2015-01-23 13:09:30 +00:00
|
|
|
}
|
2015-11-26 12:30:04 +00:00
|
|
|
|
|
|
|
,renderHeader: function ()
|
|
|
|
{
|
|
|
|
var th = document.createElement ('th');
|
|
|
|
|
|
|
|
if (this.title)
|
|
|
|
th.appendChild (document.createTextNode (this.title));
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|