i'm trying to figure out how to use tag helpers with grid to achieve the same functionalities as basic razor syntax. Some thing i have noticed that behave differently : data annotations are not being used, neither for Display names nor display format, i also do not have the option to autogenerate column with tag helpers.
Here is the code in my .cshtml page
@(Html.Kendo().Grid<
DemandeNonTraiteViewModel
>()
.Name("Nontraite")
.Columns(cols =>
{
cols.Bound(c => c.Date);
cols.Bound(c => c.NomComplet);
cols.Bound(c => c.NomOrganisation);
cols.Bound(c => c.DemandePAA);
cols.Bound(c => c.DemandeFDT);
cols.Bound(c => c.DemandeOrg);
})
.DataSource(ds => ds
.Ajax()
.Model(m => m.Id(p => p.Id))
.Read(r => r.Action("DemandeNonTraite_Read", "Demande", new { Area = "Identity" }))))
<
kendo-grid
name
=
"grid"
>
<
columns
>
<
column
field
=
"Date"
/>
<
column
field
=
"NomComplet"
/>
<
column
field
=
"NomOrganisation"
/>
<
column
field
=
"DemandePAA"
/>
<
column
field
=
"DemandeFDT"
/>
<
column
field
=
"DemandeOrg"
/>
</
columns
>
<
datasource
type
=
"DataSourceTagHelperType.Ajax"
>
<
schema
>
<
model
id
=
"Id"
>
</
model
>
</
schema
>
<
transport
>
<
read
url
=
"@Url.Action("
DemandeNonTraite_Read","Demande", new {
Area
=
"Identity"
})" />
</
transport
>
</
datasource
>
</
kendo-grid
>
Here is my viewmodel:
public class DemandeNonTraiteViewModel
{
public Guid Id { get; set; }
[Display(Name = "Date")]
[DisplayFormat(DataFormatString = "{0:d}")]
public DateTime Date { get; set; }
public string Prenom { get; set; }
public string Nom { get; set; }
public string NomOrganisation { get; set; }
[Display(Name = "PAA")]
public bool DemandePAA { get; set; }
[Display(Name = "FDT")]
public bool DemandeFDT { get; set; }
[Display(Name = "Ajout organisation")]
public bool DemandeOrg { get; set; }
[Display(Name = "Nom complet")]
public string NomComplet
{
get
{
return $"{Prenom} {Nom}";
}
}
}
And attached are the grid that are rendered . i would love to have both render with same way as the first so that i can use taghelpers instead of razor syntax