Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    European float parsing from float input field

    Hello,

    In SmartGWT 3.0 Power, is it possible to let a user type 3,0 (european style, where he meant the 3.0 american equivalent) in a float typed listgrid field?

    Currently the validator trips on it. I couldn't find it after googling and looking in the docs..
    Last edited by Sytematic; 2 May 2012, 00:00.

    #2
    I tried the following on a float field:

    Code:
    myField.setEditValueParser(new CellEditValueParser(){
    		public Object parse(Object value, ListGridRecord record,
    				int rowNum, int colNum) {
    			if(value == null)
    				return null;
    			
    			String d = String.valueOf(value);
    			
    			String[] pieces = d.split(",");
    						
    			if(pieces.length == 1){
    				return value;
    			}
    			else if(pieces.length > 1){
    				return d.replace(",", ".");
    			}
    			else {
    				Log.warn("Invalid value,  returning null");
    				return null;
    			}
    						
    		}
    					
    	});
    This kind of work, but I get the feeling that any cellFormatters are not called after modifying the field. Because next to this ValueParser, I also apply a CellFormatter.

    Am I using this the intended way?

    Comment

    Working...
    X