I’m having some trouble with date formatting (also visually in edit mode) in a Calendar and CalendarA fields.
The server wants the format “%Y-%m-%d” which makes perfect sense.
However, the user wants to use the format “%d-%m-%Y” both visually and for editing.
I can make the visual presentation work by using the method mygrid.setDateFormat(“%d-%m-%Y”, “%Y-%m-%d”) but when the field goes into edit mode (stage = 1), the server_mask is used and what was “14-05-2016” becomes “2016-04-14” in the open cell editor and that’s not what the users want.
I have tried to change this value in the open editor by altering the value of the native editor, but because this isn’t the format the server wants, the dates become invalid and I have had no luck changing the values back to the server preferred format prior to it being sent to the server.
Ok, according to the support this behavior is by design.
I don’t really see the purpose of the setDateFormat method though, if the open editor will present the format “yyyy-mm-dd” regardless of what was set via the setDateFormat method.
Setting a format/mask for one mode (display mode) and not the other (edit mode) will only confuse the user.
Anyway, if this is the case, then I will have to change my “dhxCalendarA” columns to “ed” so I can format and mask the values myself (both in read-only and edit mode).
I will lose the date picker feature by doing so, but I don’t see any alternative.
So if this is the new approach, how do I “catch” the updated value and change it to the correct server format?
What I’m asking is not how to change “dd-mm-yyyy” to “yyyy-mm-dd”, but how to make sure that what is sent to the server is “yyyy-mm-dd” regardless of what was typed in the grid cell editor… Where to catch and change the value - which event?
I have tried grid.onEditCell (stage = 2), but apparently the value sent to the server is still the original value (the value typed into the grid cell editor) even though I try to change the value at this point, which of cause fails the cast to DateTime on the server-side.
I have also tried dp.onBeforeDataSending and dp.onBeforeUpdate (dp = DataProcessor object) but the data argument of those events seems to be empty.
I’m hoping that later versions of the Grid/Calendar column types + the dataprocessor now appreciate the fact that users want to be able to edit dates in the format they know and not only see dates in this format.
Is this the case?
Have the Grid or Calendar column types (alogn with the dataprocessor) been updated so that the desired format for dates is can now be shown in the column both in and out of edit mode (stage = 1).
Previously I was able to force the format simply by changing the value of the editor once it opened for editing (stage = 1), but this would break the write attempt for the dataprocessor.