Skip to content

Conversation

@StoyanGoranov
Copy link
Contributor

@StoyanGoranov StoyanGoranov commented Oct 26, 2023

Implementing CSP compatibility features and fixes.

The unsafe-inline keyword is no longer required in the "style-src".

Fixes applied to EditorTemplates when global defer is used.

@StoyanGoranov StoyanGoranov added the enhancement New feature or request label Oct 26, 2023
@StoyanGoranov StoyanGoranov self-assigned this Oct 26, 2023
Copy link
Contributor

@mihaela-lukanova mihaela-lukanova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editor templates of "Category" and "Country" fields in the "Demo_Overview_CSP" are not activated. Also, update the editors of the rets of the fields to be Kendo editors.
image

@StoyanGoranov
Copy link
Contributor Author

The editor templates of "Category" and "Country" fields in the "Demo_Overview_CSP" are not activated. Also, update the editors of the rets of the fields to be Kendo editors. image

Issue seems to be caused by global defer in Program.cs:
builder.Services.AddKendo(x => { x.DeferToScriptFiles = true; });

app.UseMiddleware<KendoDeferredScriptsMiddleware>();
since without these configurations the EditorTemplates are used correctly.
image

@StoyanGoranov
Copy link
Contributor Author

StoyanGoranov commented Nov 23, 2023

To correctly initialize EditorTemplates in Grid deferred to a script file you need to:

  1. Configure the editor ->
    @(Html.Kendo().Template().AddComponent(x => x.NumericTextBoxFor(m => m) .HtmlAttributes(new { style = "width:100%" }) .HtmlAttributes(new { title = Html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName("") })) )
  2. Configure the column ->
    columns.Bound(p => p.UnitsInStock).Title("Units").Width(105).EditorTemplateComponentName("Number");

However, the Editor Templates are still not present in data-bound Components like DropDownLists.

@StoyanGoranov
Copy link
Contributor Author

Columns that had lingering issue with displaying EditorTemplate were previously binding to a model subfield e.g Country.CoyntryNameLong instead of the field Country

@StoyanGoranov StoyanGoranov merged commit 9d2763a into master Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants