OK< I have a test for the Playground that show most of what I am
seeing. In the following code you will see that the validation
function only gets called for the first edit, never again. But there
is a difference in the behavior I see in Playground to what I see in
my app. In the Playground, subsequent attempts to put non-numeric data
in the cell result in the contents of the cell showing NaN and not the
text you type in. In my app, you get the typed in text. Something is
not working correctly in both cases, just it's not working differently
in both cases. I made a modification to my test code just now to see
what would happen if two cells shared the same validation function and
if you edit column 0 then column 1 doing the exact same thing in both
cells you are going to get different results. Yes, there is a bug
here.
Here is the code:
var doc = this.getRoot();
var d = [[1,2,3]];
var cols = ['c-1','c-2','c-3'];
tm = new qx.ui.table.model.Simple;
tm.setColumns(cols);
tm.setData(d);
t = new qx.ui.table.Table(tm);
t.setWidth(400);
t.setHeight(150);
doc.add(t);
var f = new qx.ui.table.celleditor.TextField;
var chkNum = function(value, oldValue){
doc.info('function called'); // this should get hit every time you
make an edit in the cell
if (isNaN(value))
return oldValue;
else return value;
};
var tcm = t.getTableColumnModel();
f.setValidationFunction(chkNum);
t.getTableModel().setColumnEditable(1,true);
t.getTableModel().setColumnEditable(0,true);
tcm.setCellEditorFactory(1, f);
tcm.setCellEditorFactory(0, f);
Thanks,
Jim
On Fri, Apr 24, 2009 at 1:40 AM, Alexander Back <[email protected]> wrote:
> Hi Jim,
>
> On Friday 24 April 2009 Jim Hunter wrote:
>> I had a need for the column data in a table to be only numeric.
>> Without giving it much thought I just set the renderer to Numeric but
>> when I entered new text in, naturally it allowed me to enter anything.
>> So then I added a celleditor.TextField to the column and created a
>> simple validation function to test if the data is numeric:
>>
>> var chkNum = function(value, oldValue){
>> if (isNaN(value))
>> return oldValue
>> else return value
>> }
> That sound reasonable and I've just tested your code with a demo ("Table-Cell-
> Editor") of the demobrowser and it worked out for me. All I added are the
> semicolons at the end of the "return" statements.
>
>> The FIRST time you enter data in the cell, the validation works
>> perfect. If you enter non-numeric data it gets changed back to the
>> original numeric data that was in the cell. But if you do it again
>> (and all subsequent entries), it allows the non-numeric data. No
>> validation is performed. I put a debug line in the validation function
>> and it is only called for the first edit, not on any subsequent edits.
>>
>> If this is a bug, as I am sure it is, I will enter it into the bug
>> system. Just let me know if I am loosing my mind or not. Or is there
>> an easier way to restrict data entry to be numeric data?
> As far as I can see there is no bug. It worked out for me and this is also the
> way to do it. Can you post a small code snippet? Maybe we can track down the
> issue easier this way.
>
> cheers,
> Alex
>
> ------------------------------------------------------------------------------
> Crystal Reports - New Free Runtime and 30 Day Trial
> Check out the new simplified licensign option that enables unlimited
> royalty-free distribution of the report engine for externally facing
> server and web deployment.
> http://p.sf.net/sfu/businessobjects
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel