This is a migrated thread and some comments may be shown as answers.

Grid template does not work with localization IViewLocalizer

2 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 24 Mar 2016, 10:27 PM

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 Answers, 1 is accepted

Sort by
1
Accepted
Daniel
Telerik team
answered on 29 Mar 2016, 06:01 AM
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!
 
0
Steve
Top achievements
Rank 1
answered on 29 Mar 2016, 11:45 PM

Hi,

   It works.

Thank you for your help

Tags
Grid
Asked by
Steve
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Steve
Top achievements
Rank 1
Share this question
or