How to change date format for Admin interface?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
Yes. until Telerik fixes this issue
12 years ago
I fixed this problem by adding this line to the _AdminLayout.cshtml file just before the </body> tag

   @(Html.Telerik().ScriptRegistrar()
        .OnDocumentReady(@<text></text>) //Telerik: This is required because there is still no Telerik components on the page and jQuery(document).ready will not be rendered and the globalization will not work
        .Globalization(true))

There seems to be an issue with the globalization in the telerik components. see also: http://stackoverflow.com/questions/7678965/telerik-datetime-format-in-custom-grid-editor-template-is-not-correctly-passed-t

Now you can set your desired culture for the admin in the global.asax.cs file and date/time gets being displayed in that format.
12 years ago
backco wrote:
I fixed this problem by adding this line to the _AdminLayout.cshtml file just before the </body> tag

   @(Html.Telerik().ScriptRegistrar()
        .OnDocumentReady(@<text></text>) //Telerik: This is required because there is still no Telerik components on the page and jQuery(document).ready will not be rendered and the globalization will not work
        .Globalization(true))

There seems to be an issue with the globalization in the telerik components. see also: http://stackoverflow.com/questions/7678965/telerik-datetime-format-in-custom-grid-editor-template-is-not-correctly-passed-t

Now you can set your desired culture for the admin in the global.asax.cs file and date/time gets being displayed in that format.

Thanks for suggestion. But it's still causing some issues. For example, set the culture of your language to 'ru-RU' (Russian numbers have difference format). Go to any admin area page which has a decimal input. For example enter 12345,67 product price (12345 dollars and 67 cents) and I'll get the following validation error "The field Price must be a number"
12 years ago
Anyone know how to change the date picker to a dynamic calendar in checkout attributes?
12 years ago
a.m. wrote:
Yes. until Telerik fixes this issue


It's not a Telerik issue, but an issue with the unobtrusive validation.

After implementing the fix as described in this topic I changed "number" validation method in the jquery.validate.min.js file to allow a , as decimal separator instead of a .

A better solution would be to implement Jquery globalization.
But due to time constraints I couldn't get it working yet.

But you can easily hardcode the admin locale to a different one using this hack.
12 years ago
The problem lies in telerik's not using String.ToLowerInvariant() method, I believe this has been fixed in more recent versions... I will test it and let you know my results.....

You also have to change @(MvcHtmlString.Create(HttpUtility.HtmlDecode(Html.Telerik().ScriptRegistrar() to @(MvcHtmlString.Create(HttpUtility.HtmlDecode(Html.Telerik().ScriptRegistrar().Globalization(true) in _AdminLayout.cshtml
12 years ago
Updated the telerik dll added the jquery globalize script and made the changes to _AdminLayout.cshtml and everything seems to be functioning ok so far..... It's good when I change the culture to Russian, if I come across any problems will let you know.
12 years ago
@james.roche76

Could you share the changes in _adminlayout.cshtml to get jquery globalize working with us?
12 years ago
sure first you need to get the globalize script http://github.com/jquery/globalize and add it to your scripts directory...
The add this to head section (under the jquery scripts):

<script src="@Url.Content("~/Scripts/globalizejs")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/cultures/cultures.js")" type="text/javascript"></script>
<script type="text/javascript">
$.validator.methods.number = function (value, element) {
    return !isNaN(Globalize.parseFloat(value));
}
    Globalize.culture = Globalize.cultures["@Html.Raw(currentCulture)"];
</script>


the also have culture specific scripts so instead of get all the supported cultures in cultures.js

Then just at the bottom of the file replace the following line:
@(MvcHtmlString.Create(HttpUtility.HtmlDecode(Html.Telerik().ScriptRegistrar()
with
@(MvcHtmlString.Create(HttpUtility.HtmlDecode(Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text></text>).Globalization(true)
    .jQuery(false).ToHtmlString())))

In order to get it working 100% you need to make some changes in the views (for the correct globalization of decimals when not in edit of telerik grid etc... see the globalize documentation) but doing this was adequate for my needs....

Hope that helps
12 years ago
the above scripts must be under the validator script, I put it under all the rerference to jquery plugins.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.