Unplanned
Last Updated: 23 Sep 2024 16:05 by Emily
Emily
Created on: 12 Sep 2024 19:07
Category: Grid
Type: Feature Request
3
CSP Grid Popup Editor Template

I'm in the process of rewriting all Kendo components to use CSP compatible templates. I'm looking at https://docs.telerik.com/aspnet-core/html-helpers/template/overview which shows how we'd use TemplateComponentName() for popup editors and that we would need to rewrite everything in the popup editor to use Kendo Template's AddHtml or AddComponent methods.

Original:

<div class="mb-2 row required"> @Html.LabelFor(model => model.FileName, new { @class = "col-sm-4 col-form-label fw-bold text-sm-end" }) <div class="col-sm-6"> @(Html.Kendo().TextBoxFor(model => model.FileName).HtmlAttributes(new { @class = "w-100" })) </div> </div> <div class="mb-2 row"> @Html.LabelFor(model => model.FileDescription, new { @class = "col-sm-4 col-form-label fw-bold text-sm-end" }) <div class="col-sm-6"> @(Html.Kendo().TextBoxFor(model => model.FileDescription).HtmlAttributes(new { @class = "w-100" })) </div> </div>

Rewritten:

@(Html.Kendo().Template()
	.AddHtml("<div class='mb-2 row required'>")
	.AddHtml(@<text>
		@Html.LabelFor(model => model.FileName, new { @class = "col-sm-4 col-form-label fw-bold text-sm-end" })
	</text>)
	.AddHtml("<div class='col-sm-6'>")
	.AddComponent(c => c.TextBoxFor(model => model.FileName).HtmlAttributes(new { @class = "w-100" }))
	.AddHtml("</div></div>")

	.AddHtml("<div class='mb-2 row'>")
	.AddHtml(@<text>
		@Html.LabelFor(model => model.FileDescription, new { @class = "col-sm-4 col-form-label fw-bold text-sm-end" })
	</text>)
	.AddHtml("<div class='col-sm-6'>")
	.AddComponent(c => c.TextBoxFor(model => model.FileDescription).HtmlAttributes(new { @class = "w-100" }))
	.AddHtml("</div></div>")
)

While this works, this markup seems much harder to read than the original. Could this be made to be simpler? Ideally I'd like to be able to drop my existing mix of html and kendo components in one method and it'd parse through to render the template properly.

 

3 comments
Emily
Posted on: 23 Sep 2024 16:05
Thank you for discussing this with your development team Mihaela! If it's achievable, I hope you and your team will consider this feature in the next few releases. Kendo grid's popup editor is something we use frequently across our applications so this would drastically improve our efforts to convert them over to CSP compliant templates.
ADMIN
Mihaela
Posted on: 20 Sep 2024 15:53

Hello Emily,

Your idea about the parser method is great and achievable. 

We will monitor the interest in the item and consider it for implementation in the future, based on the community interest.

Regards,
Mihaela
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

ADMIN
Mihaela
Posted on: 19 Sep 2024 14:35

Hello Emily,

Thank you for the provided code snippets.

We will discuss internally with the development team if such parser method that returns a Template component can be implemented and I will get back to you wit more information.

Regards,
Mihaela
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.