Currently I’m developing a webapp using Vaadin 7.5 and I stumbled across and issue I have not been able to solve by reading this community or other online sources. My problem as follows…
I have applied the editor UI to my grid, via the myGrid.setEditorEnabled(true). As for now, I know how to change the Save and Cancel captions, but I have not been able to do much else.
For example, on my Grid I have formatted some dates to appear as “2015-Dec-16” by using the DateRenderer. But once I double click on the editor, I lose temporarily that format while editing. This happens not only for dates, but any other format.
Could you guys shed a light on my issue? I appreciate your help very much.
The Renderer doesn’t affect the Editor, as you have noticed. You need to set an editor Field to the column instead. In the case of a date you want formatted, you can use the DateField, which can take a date format like DateRenderer.
Sample code:
[code]
grid.setEditorEnabled(true);
Column dobColumn = grid.getColumn("dateOfBirth");
dobColumn.setRenderer(
new DateRenderer(new SimpleDateFormat("yyyy-MMM-dd")));
DateField df = new DateField();
df.setDateFormat("yyyy-MMM-dd");
dobColumn.setEditorField(df);