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

[Solved] Bug In Global Resource Files (Script Error)

0 Answers 24 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brad
Top achievements
Rank 1
Brad asked on 30 Dec 2011, 10:19 PM
After hours of trying to figure out my problem... I finally figured our that double quotes are not being escaped (e.g. \"{0}\"} in the localization resource files specifically for the editor (I don't know what other resource files may have this issue or if it's just MVC...).

I'm using the editor with 2011.3.1115. I kept getting a script error (from FireFox console "missing } after property list") - and of course this is difficult to debug when it gives you the reference to the jquery-1.6.4 js file - yet the line of code (containing thousands of characters) starts with "if(!jQuery.telerik)". I can only replicate the issue (in every browser) when using AJAX binding with nested grids and an editor within the editing template for the grid in the ClientTemplate of the DetailView (Code below). The grid itself inside the ClientTemplate is fine by itself when not inside the ClientTemplate of the DetailView.

@(Html.Telerik().Grid<CustomSectionHtmlItem>()
                .Name("HomeText")
                        .DataKeys(keys =>
                        {
                            keys.Add(dk => dk.HtmlID).RouteKey("HtmlID");
                            keys.Add(dk => dk.SectionID).RouteKey("SectionID");
                        })
                .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
                .DataBinding(db => db.Ajax()
                    .Select("_SelectSectionHtmlItems", "CustomHtml")
                    .Update("_UpdateSectionHtmlItems", "CustomHtml")
                    .Insert("_InsertSectionHtmlItems", "CustomHtml")
                    .Delete("_DeleteSectionHtmlItems", "CustomHtml")
                    )
                    .Columns(cols =>
                    {
                        cols.Bound(csh => csh.SectionID).ClientTemplate("<#= SectionName #>").EditorTemplateName("MainSectionChooser");
                        cols.Bound(csh => csh.HtmlID).Hidden();
                        cols.Bound(csh => csh.TitleDisplayString);
                        cols.Command(commands =>
                        {
                            commands.Edit().ButtonType(GridButtonType.Image);
                            commands.Delete().ButtonType(GridButtonType.Image);
 
                        });
                    })
                .Editable(edit => edit.Mode(GridEditMode.InLine).DisplayDeleteConfirmation(true))
                .DetailView(dv => dv.ClientTemplate(
                    Html.Telerik().Grid<HtmlTextItem>()
                                    .Name("SectionText_<#= SectionName #>")
                                    .DataKeys(keys =>
                                    {
                                        keys.Add(dk => dk.HtmlID).RouteKey("HtmlID");
                                        keys.Add(dk => dk.LangIetfTag).RouteKey("LangIetfTag");
                                    })
                                    .ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Image))
                                    .DataBinding(db => db.Ajax()
                                        .Select("_SelectSectionHtmlTexts", "CustomHtml", new { sectionID = "<#= SectionID #>" })
                                        .Update("_UpdateSectionHtmlTexts", "CustomHtml", new { sectionID = "<#= SectionID #>" })
                                        .Insert("_InsertSectionHtmlTexts", "CustomHtml", new { sectionID = "<#= SectionID #>" })
                                        .Delete("_DeleteSectionHtmlTexts", "CustomHtml", new { sectionID = "<#= SectionID #>" })
                                    )
                                    .Columns(cols =>
                                    {
                                        cols.Bound(lp => lp.LangIetfTag);
                                        cols.Bound(lp => lp.HtmlText).Encoded(false);
                                        cols.Command(commands =>
                                        {
                                            commands.Edit().ButtonType(GridButtonType.Image);
                                            commands.Delete().ButtonType(GridButtonType.Image);
                                        });
                                    })
                                    .Editable(editing => editing.Mode(GridEditMode.PopUp)
                                                            .Window(w => w.Width(500).Height(500))
                                                            .TemplateName("HtmlEditorTemplate")
                                                            .DisplayDeleteConfirmation(true))
                                    .ToHtmlString()
                 ))
 
                )


The HtmlEditorTempalte has dropdown for language and the editor itself. I would only get the error after expanding the first row (where it would call the Ajax Select Action) and then clicking edit or insert which would bring up the editor template with the editor in PopUp Mode - that's when the JS error occured, the editor would render but the JS error stopped it somewhere because none of the tool buttons would work (nor did the template popup window say "Insert" or "Edit" in the title.

I couldn't wrap by brain around the error. I tried everything and searching for this yielded nothing. I replaced the editor with a straight up text area and everything was fine - and again, the nested grid (with the same editor template) worked fine when it wasn't used as a ClientTemplate inside the DetailView of another grid.

I finally dissected the line and found that the script error column number fell around this stmt:
"deleteFile":"Are you sure you want to delete "{0}"?"

Looking in the resx files (first EditorLocalization.en-US.resx), I saw this exact line as the value for the "DeleteFile" key.... some other keys such as "InvalidFileType" had the double quotes escaped (i.e. The selected file \"{0}\" is not valid. Supported file types are {1}.), but "OverwriteFile" didn't. I escaped the double quotes (e.g. \"{0}\") in DeleteFile and sure enough the same error came back but later in the line of code - for "OverwriteFile" - fixed that, and everything worked.

I'm not sure why this only happens when it's within the ClientTemplate of a DetailView or what other resource files it affects - and whether it's just the MVC product specifically... but I assume these need to be fixed. I also don't know if it's isolated to double quotes around the brackets, or all double quotes in general (as they are used in the resource files around literals instead of bracket arguments).
Tags
Editor
Asked by
Brad
Top achievements
Rank 1
Share this question
or