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

Kendo editable template and French characters decoding

2 Answers 268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 26 Jul 2013, 01:29 PM
I use ressource files to translate the website labels. All is fine in every part of the website but in the popup to edit an item in my kendo Grid, my characters aren't decoded. My grid uses an editable popup which itself use a template. My grid is define itself in a template because i use nested Grids (this one is on the 4th level). Every level is created using ClientDetailTemplateId()
My View :

01.  <script id="LicenceGridTemplate" type="text/kendo-tmpl">
02.    @(Html.Kendo().Grid<Administration.Models.LicenceModel>()
03.        .Name("LicenceGrid_#=UserID#")
04.        .DataSource(dataSource => dataSource
05.            .Ajax()
06.            .Read(read => read.Action("GetLicences", "Licence", new { userID = "#=UserID#" }).Type(HttpVerbs.Get))
07.            .Model(m =>
08.            {
09.                if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
10.                {
11.                    m.Field(f => f.ApprovalState).DefaultValue(PAService.PartnerEDM.ApprovalState.Approved);
12.                }
13.                m.Id(l => l.LicenceID);
14.            })
15.            .Create(update =>
16.            {
17.                if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
18.                {
19.                    update.Action("AddLicence", "Licence").Data("GetLicenceAdditionalData");
20.                }
21.                else
22.                {
23.                    update.Action("RequestLicence", "Licence").Data("GetLicenceAdditionalData");
24.                }
25.            })
26.            .Update(update =>
27.            {
28.                if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
29.                {
30.                    update.Action("EditLicence", "Licence").Type(HttpVerbs.Post);
31.                }
32.            })
33.            .Events(e => e.Error("grid_error"))
34.        )
35.        .Columns(columns =>
36.        {
37.            columns.Bound(m => m.ApprovalState);
38.            columns.Bound(m => m.CentralPoint);
39.            columns.Bound(m => m.NextExpirationDate).Format("{0:d}").HtmlAttributes(new { cellType = "NextExpirationDate" }).Width(160);
40.            columns.Bound(m => m.SerialNumber);
41.            columns.Bound(m => m.WebLicenseCount).HtmlAttributes(new { cellType = "WebCount" });
42.            columns.Bound(m => m.MobileLicenseCount).HtmlAttributes(new { cellType = "MobileCount" });
43.            columns.Bound(m => m.ExcelAddInLicenseCount).HtmlAttributes(new { cellType = "ExcelCount" });
44.            if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
45.            {
46.                columns.Command(command => command.Edit().Text(" ")).Width(100);
47.            }
48.        })
49.        .ToolBar(toolbar =>
50.        {
51.            if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
52.            {
53.                toolbar.Create().Text(@ressourceManager.GetString("Add"));
54.            }
55.            else
56.            {
57.                toolbar.Create().Text(@ressourceManager.GetString("RequestLicence"));
58.            }
59.        })
60.        .Editable(editable =>
61.        {
62.            editable.Mode(GridEditMode.PopUp);
63.            if (currentUser.Type == (int)PAService.PartnerEDM.UserRole.Admin)
64.            {
65.            editable.TemplateName("LicenceEditTemplate");
66.            }
67.            else
68.            {
69.                editable.TemplateName("LicenceRequestTemplate");
70.            }
71.            editable.Window(w => w.Width(600));
72.        })
73.        .Events(e => e
74.            .Edit("AdaptLicenceEditPopup")
75.            .DataBound("UpdateDatesColors")
76.            .Save("UpdateCalculatedFields")
77.            .DetailExpand("grid_detailexpand")
78.            .Cancel("Cancel")
79.        )
80.        .Sortable()
81.        .Filterable()
82.        .Resizable(resize => resize.Columns(true))
83.        .ToClientTemplate()
84.    )
85.</script>


The problematic label:
1.@Html.LabelFor(l => l.IsDemo)


Which get its name from:

1.[LocalizedDisplayName("IsDemoLicence")]
2.public bool IsDemo { get; set; }

which render as State in English, but as &201;tat in French. Note that the same label is decoded correctly outside of the popup (in my grid headers).
What am I doing wrong? Thanks in advance.

UPDATE : The popup decode the characters correctly for the top level grid, which means that the problem seems to come from the templates.

2 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 30 Jul 2013, 01:38 PM
Hi Simon,

 
Basically current behavior is expected and I would suggest to use the edit event of the Grid to find all labels inside the current container and decode their values. Please check the example below:

function onEdit(e) {
    e.container.find("label").each(function () {
        var currentLabeltext = $(this).text();
        //decode the HTML
        $(this).html(currentLabeltext);
    })
}
Kind  Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Simon
Top achievements
Rank 1
answered on 30 Jul 2013, 02:23 PM
Thank you I will try this solution!
Tags
Grid
Asked by
Simon
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Simon
Top achievements
Rank 1
Share this question
or