]>
git.argeo.org Git - gpl/argeo-slc.git/blob - server/org.argeo.slc.ria/src/argeo-ria-lib/slc/class/org/argeo/slc/ria/execution/CellEditorFactory.js
1 /*******************************************************************************
5 ******************************************************************************/
8 * A cell editor factory creating text fields or disabled text fields.
11 qx
.Class
.define("org.argeo.slc.ria.execution.CellEditorFactory",
13 extend
: qx
.ui
.table
.cellrenderer
.Default
,
14 implement
: qx
.ui
.table
.ICellEditorFactory
,
17 * ****************************************************************************
19 * ****************************************************************************
22 construct : function() {
27 * ****************************************************************************
29 * ****************************************************************************
35 * function that validates the result the function will be called with
36 * the new value and the old value and is supposed to return the value
37 * that is set as the table value.
39 validationFunction
: {
48 * ****************************************************************************
50 * ****************************************************************************
55 _getContentHtml : function(cellInfo
) {
56 var table
= cellInfo
.table
;
57 var tableModel
= table
.getTableModel();
58 var rowData
= tableModel
.getRowData(cellInfo
.row
);
59 var metaData
= rowData
[2];
60 if (metaData
.disabled
) {
61 return '<span style="color:#999;">' + qx
.bom
.String
.escape(this._formatValue(cellInfo
)) + '</span>';
63 return qx
.bom
.String
.escape(this._formatValue(cellInfo
));
68 // interface implementation
69 createCellEditor : function(cellInfo
) {
70 var table
= cellInfo
.table
;
71 var tableModel
= table
.getTableModel();
72 var rowData
= tableModel
.getRowData(cellInfo
.row
);
73 var metaData
= rowData
[2];
74 if (metaData
.disabled
) {
75 return null; // var cellEditor = new
76 // qx.ui.table.celleditor.TextField();
79 var cellEditor
= new qx
.ui
.form
.TextField
;
80 cellEditor
.setAppearance("table-editor-textfield");
81 cellEditor
.originalValue
= cellInfo
.value
;
82 if (cellInfo
.value
=== null) {
85 cellEditor
.setValue("" + cellInfo
.value
);
87 cellEditor
.addListener("appear", function() {
88 cellEditor
.selectAll();
92 if (metaData
.subType
== "integer") {
93 validationFunc = function(newValue
, oldValue
){
94 var isNum
= !isNaN(newValue
* 1);
96 alert("Warning, this field only accepts Integers!");
103 cellEditor
.setUserData("validationFunc", validationFunc
);
108 // interface implementation
109 getCellEditorValue : function(cellEditor
) {
110 var value
= cellEditor
.getValue();
111 var validationFunc
= cellEditor
.getUserData("validationFunc");
113 // validation function will be called with new and old value
114 // var validationFunc = this.getValidationFunction();
115 if (validationFunc
) {
116 value
= validationFunc(value
, cellEditor
.originalValue
);
119 if (typeof cellEditor
.originalValue
== "number") {
120 value
= parseFloat(value
);