Trace:
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
jvx:client:gui:celleditor_dateformat [2021/02/01 12:46] admin created |
jvx:client:gui:celleditor_dateformat [2024/11/18 10:31] (current) admin |
||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ~~Title: Change date format of Cell Editor~~ | ~~Title: Change date format of Cell Editor~~ | ||
| + | To set a custom date format on a date cell, simply use following code: | ||
| + | |||
| + | <code java> | ||
| + | UIDateCellEditor dateEditor = new UIDateCellEditor(); | ||
| + | //use long pre-configured date format | ||
| + | dateEditor.setDateFormat(((SimpleDateFormat)SimpleDateFormat.getDateInstance(SimpleDateFormat.LONG)).toPattern()); | ||
| + | </code> | ||
| + | or use a custom format | ||
| + | <code java> | ||
| + | dateEditor.setDateFormat("yyyy-MM-dd"); | ||
| + | </code> | ||
| + | |||
| + | Above statements will create a date cell editor with configured date format. To apply the format, simply set the cell editor | ||
| + | |||
| + | <code java> | ||
| + | databook.getRowDefinition().getColumnDefinition("COLUMN_NAME").getDataType().setCellEditor(dateEditor); | ||
| + | </code> | ||
| + | |||
| + | It's not necessary to create multiple date cell editors for the same format, simply re-use existing instances. | ||
| + | |||
| + | We have some static cell editors in our [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/library/src/jvx/rad/application/ApplicationUtil.java|ApplicationUtil]] class, e.g. | ||
| + | |||
| + | <code java> | ||
| + | IMAGE_VIEWER | ||
| + | </code> | ||
| + | We recommend that you create a utility class for your cell editors as well. | ||
