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

Grid with TagHelpers

3 Answers 383 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bruce
Top achievements
Rank 1
Bruce asked on 04 Jul 2019, 07:10 AM

I can't find where to indicate the model i.e what's the equavalent of  @(Html.Kendo().Grid<Model> in the TagHelper syntax.

Without the model I can't get intellisense for my grid columns and inferred column names (DataAnnotation) are missing.

 

 

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 09 Jul 2019, 06:13 AM
Hi Bruce,

The TagHelpers are aiming for providing a strongly-typed HTML. They are introduced in order to allow the user to use built-in methods and properties instead of plain text and attributes. They pretty much get closer to the implementation of the Kendo UI jQuery widgets. 

In other words, with the TagHelpers strongly typed classes cannot be used. Hence, there is no model declaration at all. This declaration is not created because we are following the conventions of Microsoft.

There would be no intellisense for the column declaration of the grid. But, you can declare the columns following the same naming as the properties in the main model. The grid would be still bound to a collection of models.

If you would like to apply validation to certain columns, then you would have to do so by setting up the validation tag. It is part of the schema model declaration of the data source.

Let me know in case additional clarifications are needed.


Kind regards,
Tsvetomir
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Mark
Top achievements
Rank 1
answered on 04 Dec 2019, 06:01 AM

If I can jump in and add to this -

I believe "following the conventions of Microsoft" is an incorrect in this context - ASP.NET Core 3.1 use server side binding in the way described by the OP at the most base level.

For example, the LabelTagHelper and the InputTagHelper both implement the asp-for attribute, solely for the purpose to (within the Tag Helper) pull in validation attributes of the property being bound.

Without this, it means I would be duplicating my validation by having validation twice server side; in attributes in my class, and within my views - both doing exactly the same validation (albeit in separate client/server environments).

Would like to see this kind of binding in someway via the Grid (and other Telerik) Tag Helper(s) - they are must easier to read/understand, and using the older approach of Html Helpers seem to be going against the grain with respect to ASP.NET Core development.

0
Tsvetomir
Telerik team
answered on 06 Dec 2019, 01:53 PM

Hi Mark,

It is correct that the asp-for attribute has been implemented for the TagHelper. However, the primary aim is to bind a form control to its corresponding field in the model. While this is possible in the context of having a form with a model and editors, the Kendo UI Grid is not a form control or an editor template. The validation cannot be pulled from the page model due to the fact that the majority of the cases there is a dedicated model for the grid. 

Moreover, it is always recommended to have both server-side and client-side validation. Even though they might be the same, the client-side validation saves unnecessary trips to the server-side. The only downside would be the fact that the client-side validation rules have to be implemented explicitly.

I hope you find those clarifications.

 

Best regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Bruce
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Mark
Top achievements
Rank 1
Share this question
or