Grid template does not work with localization IViewLocalizer

3 posts, 1 answers
  1. Steve
    Steve avatar
    22 posts
    Member since:
    Feb 2016

    Posted 24 Mar 2016 Link to this post

    Hi,

       I'm using Kendo UI Grid with a custom popup editor template and AngularJs.  I'm also using localization like this example with IViewLocalizer.  However, localization replace the exclamation mark by ' so my template is crashing with this error:

    angular.js:13236 Error: Invalid template:'
                    <div dir-loadtemplate>
                        <div class="k-edit-label"><label for="AssignmentType">Type d&#x27;assignation :</label></div>
                        <!--<div class="k-edit-field"><input ng-model="AssignmentType.AssignmentTypeId" k-options="assignmentDropDownOptions" kendo-dropdownlist k-value-primitive="false"  /></div>-->
                        <div class="k-edit-field">
                            <select name="AssignmentType" id="AssignmentType" k-on-change="onChangeAssignmentType(kendoEvent)" data-bind="value: AssignmentType" k-data-source="assignmentTypeDataSource" kendo-dropdownlist k-data-text-field="'Description'" k-data-value-field="'Id'" data-option-label="{Description:'',Id:null}" data-assignmentTypeValidation-msg="Assignment type is required" />
                            <span class="k-invalid-msg" data-for="AssignmentType"></span>
                        </div>

    Source code is very simple:

    <script type="text/x-kendo-template" id="template">
                    <div dir-loadtemplate>
                        <div class="k-edit-label"><label for="AssignmentType">@LocString["STR_AssignmentType"] :</label></div>
                        <!--<div class="k-edit-field"><input ng-model="AssignmentType.AssignmentTypeId" k-options="assignmentDropDownOptions" kendo-dropdownlist k-value-primitive="false"  /></div>-->
                        <div class="k-edit-field">
                            <select name="AssignmentType" id="AssignmentType" k-on-change="onChangeAssignmentType(kendoEvent)" data-bind="value: AssignmentType" k-data-source="assignmentTypeDataSource" kendo-dropdownlist k-data-text-field="'Description'" k-data-value-field="'Id'" data-option-label="{Description:'',Id:null}" data-assignmentTypeValidation-msg="Assignment type is required" />
                            <span class="k-invalid-msg" data-for="AssignmentType"></span>
                        </div>

     

    I tried to replace ' by '' in the localization methode without success:

    protected string GetStringSafely(string name, CultureInfo culture)
            {
                var resourceValue = string.Empty;
    #if DNX452
                var cultureName = (culture ?? CultureInfo.CurrentUICulture).Name;
                //var resourceFile = _resourceManager.BaseName.Substring(_resourceManager.BaseName.IndexOf('.') + 1) + "." + cultureName;
                var resourceFile = "Resource" + "." + cultureName;
                var filePath = Path.Combine(_applicationBasePath, "Resources", "bin");
     
                if (File.Exists(Path.Combine(filePath, resourceFile + ".resources")))
                {
                       _resourceManager = ResourceManager.CreateFileBasedResourceManager(resourceFile, filePath, null);
                }
    #endif
                try
                {
                    // retrieve the value of the specified key
                    resourceValue = _resourceManager.GetString(name).Replace("'", "''");
                }
                catch (MissingManifestResourceException)
                {
                    return name;
                }
                return resourceValue;
            }

     

    Any idea how to fix it?

    Thank you

  2. Answer
    Daniel
    Admin
    Daniel avatar
    2231 posts

    Posted 29 Mar 2016 Link to this post

    Hi,

    Could you try with the Html.Raw helper:
    @Html.Raw(LocString["STR_AssignmentType"])

    It should prevent encoding the value.

    Regards,
    Daniel
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Steve
    Steve avatar
    22 posts
    Member since:
    Feb 2016

    Posted 29 Mar 2016 in reply to Daniel Link to this post

    Hi,

       It works.

    Thank you for your help

Back to Top