This question is locked. New answers and comments are not allowed.
Hi,
I am using the grid in dynamically (AJAX) loaded views. This works fine until globalization comes into play...
1) ScriptRegistrar won't output globalization information
When you put a Telerik component directly on the view, @Html.Telerik().ScriptRegistrar().Globalization(true) (which is part of my _Layout.cshtml) will output culture specific information in a CDATA block.
However, because my main view has just some HTML skeleton and the real content is loaded via AJAX, the ScriptRegistrar will output nothing! While the grid itself will automatically load the needed JavaScript files in the partial view, the culture info is missing. Therefore, numbers and dates are formatted incorrectly.
I worked around this by adding the JavaScript-files to the ScriptRegistrar and forcing it to output the CDATA block with the culture info. The following snippet does the job for me:
Note the OnDocumentReady-Funktion which actually triggers the output of the CDATA block!
Now, numbers are formatted correctly, even after sorting and paging with AJAX.
BTW: This took my almost 2 days to track down and find the above workaround.
However, I still have a problem: When I edit a row (let's say in German culture) the number "2,5" switches to "2.5". Of course this leads to validation problems. If I manually change the "." back to "," everything works as expected (And yes, I use Globalize.js to localize JQuery validation, works great!).
Any ideas why this display uses the correct formatting vs. editing uses the default formatting?
Regards Hartmut
I am using the grid in dynamically (AJAX) loaded views. This works fine until globalization comes into play...
1) ScriptRegistrar won't output globalization information
When you put a Telerik component directly on the view, @Html.Telerik().ScriptRegistrar().Globalization(true) (which is part of my _Layout.cshtml) will output culture specific information in a CDATA block.
However, because my main view has just some HTML skeleton and the real content is loaded via AJAX, the ScriptRegistrar will output nothing! While the grid itself will automatically load the needed JavaScript files in the partial view, the culture info is missing. Therefore, numbers and dates are formatted incorrectly.
I worked around this by adding the JavaScript-files to the ScriptRegistrar and forcing it to output the CDATA block with the culture info. The following snippet does the job for me:
@Html.Telerik().ScriptRegistrar().Globalization(true).DefaultGroup(a =>
{
a.Add("~/Scripts/2011.2.914/telerik.common.min.js");
a.Add("~/Scripts/2011.2.914/telerik.grid.min.js");
a.Add("~/Scripts/2011.2.914/telerik.textbox.min.js");
a.Add("~/Scripts/2011.2.914/telerik.grid.editing.min.js");
}).OnDocumentReady(()=>{}))Now, numbers are formatted correctly, even after sorting and paging with AJAX.
BTW: This took my almost 2 days to track down and find the above workaround.
However, I still have a problem: When I edit a row (let's say in German culture) the number "2,5" switches to "2.5". Of course this leads to validation problems. If I manually change the "." back to "," everything works as expected (And yes, I use Globalize.js to localize JQuery validation, works great!).
Any ideas why this display uses the correct formatting vs. editing uses the default formatting?
Regards Hartmut