Hi Volkan,
I'm trying to customize date and datetime format both in a grid and in a dialog, but without any success...I was playing with DateTimeFormatter and DisplayFormat attributes but I'm doing something wrong because the date and datetime are always displayed in the same format...
Moreover, there is any way to hide the date/time picker when such fields is ReadOnly(true) ?
Or it's better to force the field to use another editor type? I tried to force a datetime field with a StringEditor but once again I don't know how to control the output format (that in such case in something like "dateTtime".
Edit: DisplayFormat do the job on grids.
Thanks
Regards
Columns and editors are different things. DisplayFormat works on columns. Editors uses server Culture, not UI culture. This culture info is transferred to script side from LayoutHead.cshtml.
< script type="application/json" id="ScriptCulture">@Html.Raw(Serenity.JSON.Stringify(new ScriptCulture()))</ script>
You may change culture in web.config, or override ScriptCulture settings transferred to client side here, e.g. new ScriptCulture { DateFormat = .... }
Copy that!
But which is the right approach to show a date/datetime readonly calculated field on a dialog (for example LastUpdate or Created) with a custom format and without (I mean hidden and not disabled) the time picker icon?
Thanks in advance
ReadOnly should hide button, what is version you are using??
Not hide disable actually
Exactly the picker is disabled and not hidden.
I'm trying to hide the picker because such date/datetime fields are always readonly in my dialog...perhaps I can force a StringEditor? In that way I obtain a disabled control without picker (obviously), but I haven't control on the output format (that is something like "dateTtime").
Any suggestion to achieve that result/behaviour?
Edit: I'm using version 1.9.17
Thanks in advance
Regards
I don't understand why its so important to hide picker image but you can hide it with CSS
.s-MyDialog .MyReadOnlyField .ui-datepicker-trigger { display: none }
Check classes, i don't remember what was it
It's important (at least for us) to give users the feeling that such field will never be editable.
Thanks
In hiding the disable button.. add a stringfield in your row then pass the value of the datetime through expression..
Thanks @volkanceylan it works,
<script type="application/json" id="ScriptCulture">
@Html.Raw(Serenity.JSON.Stringify(new ScriptCulture { DateFormat = "dd/MM/yyyy" }))
</script>
Most helpful comment
It's important (at least for us) to give users the feeling that such field will never be editable.
Thanks