forked from verdnatura/hedera-web
56 lines
911 B
JavaScript
56 lines
911 B
JavaScript
|
Htk.ColumnText = new Class
|
||
|
({
|
||
|
Extends: Htk.Column
|
||
|
,Tag: 'htk-column-text'
|
||
|
,Properties:
|
||
|
{
|
||
|
/**
|
||
|
* Format that applies to the value.
|
||
|
**/
|
||
|
format:
|
||
|
{
|
||
|
type: String
|
||
|
,set: function (x)
|
||
|
{
|
||
|
this._format = _(x);
|
||
|
}
|
||
|
,get: function ()
|
||
|
{
|
||
|
return this._format;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
,_format: null
|
||
|
|
||
|
,render: function (tr)
|
||
|
{
|
||
|
var node;
|
||
|
|
||
|
if (this.editable)
|
||
|
{
|
||
|
var value = this.value ? this.value : '';
|
||
|
|
||
|
node = document.createElement ('input');
|
||
|
node.type = 'text';
|
||
|
node.className = 'cell-text';
|
||
|
node.value = value;
|
||
|
node.addEventListener ('changed',
|
||
|
this.inputChanged.bind (this, tr, node));
|
||
|
}
|
||
|
else
|
||
|
node = document.createTextNode (
|
||
|
Vn.Value.format (this.value, this._format));
|
||
|
|
||
|
var td = this.parent (tr);
|
||
|
td.style.textAlign = 'left';
|
||
|
td.appendChild (node);
|
||
|
return td;
|
||
|
}
|
||
|
|
||
|
,inputChanged: function (tr, node)
|
||
|
{
|
||
|
this.changed (tr, node.value);
|
||
|
}
|
||
|
});
|