Hello,
I am struggling with trying to achieve that seconds are also displayed in a ListGrid DateTime field.
(By the way: as I see ListGrid uses short date format for this purpose, it would be nice to be able to simply change it to the default normal date format...)
So, as per the documentation, I need to change the ShortDatetimeDisplayFormatter and the DateParser.
The datetime values are displayed as expected but when I try to change the value, some default validator of the editor complains that the value "Must be a date", despite it fits to the format I had set. The date parser is not called at all.
SmartClient Version: v11.1p_2017-09-27/LGPL Development Only (built 2017-09-27)
Sample code: (try to add a new row and set any datetime)
I can't find out why is that validator complaining, how to get through it.
Can you kick me to the right direction please?
Thanks,
Balázs
I am struggling with trying to achieve that seconds are also displayed in a ListGrid DateTime field.
(By the way: as I see ListGrid uses short date format for this purpose, it would be nice to be able to simply change it to the default normal date format...)
So, as per the documentation, I need to change the ShortDatetimeDisplayFormatter and the DateParser.
The datetime values are displayed as expected but when I try to change the value, some default validator of the editor complains that the value "Must be a date", despite it fits to the format I had set. The date parser is not called at all.
SmartClient Version: v11.1p_2017-09-27/LGPL Development Only (built 2017-09-27)
Sample code: (try to add a new row and set any datetime)
Code:
public void onModuleLoad() { DateTimeFormat dateFormatter = DateTimeFormat.getFormat("yyyy.MM.dd. hh:mm:ss"); //DateUtil.setShortDatetimeDisplayFormatter(DateUtil.TOLOCALESTRING); DateUtil.setShortDatetimeDisplayFormatter(date -> dateFormatter.format(date)); DateUtil.setDateParser(dateString -> {SC.say("Not called"); return null;}); Canvas canvas = new Canvas(); final ListGrid grid = new ListGrid(); grid.setWidth(400); grid.setHeight(200); grid.setShowAllRecords(true); grid.setCanEdit(true); canvas.addChild(grid); DataSource ds = new DataSource(); ds.setClientOnly(true); DataSourceTextField countryNameDsField = new DataSourceTextField("countryName", "Country Name"); DataSourceTextField someDateTimeDsField = new DataSourceTextField("someDateTime", "Some DateTime"); someDateTimeDsField.setType(FieldType.DATETIME); ds.setFields(countryNameDsField, someDateTimeDsField); grid.setDataSource(ds); Button btn = new Button("Add"); btn.addClickHandler(event -> grid.startEditingNew()); btn.setTop(220); canvas.addChild(btn); canvas.draw(); }
Can you kick me to the right direction please?
Thanks,
Balázs
Comment