Hello,
@(Html.Kendo().Grid<Myproject.Areas.Maintenance.ViewModels.EquipementsInterventions.EquipementInterventionModel>() .Name("EquipementIntervention") .Columns(columns => { columns.Bound(p => p.NoReference).Width(60); columns.Bound(p => p.DateIntervention).Format("{0:yyyy-MM-dd}").Width(60).HtmlAttributes(new { style = "text-align:center" }); }) .ToolBar(toolBar => { toolBar.Create(); toolBar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .HtmlAttributes(new { style = "font-size:11px;height: 300px;" }) .Scrollable() .Selectable(s => s.Enabled(false)) .Pageable(pageable => pageable .Refresh(true) .ButtonCount(5)) .DataSource(dataSource => dataSource .Ajax() .Batch(true) .ServerOperation(false) .PageSize(100) .Model(model => { model.Id(field => field.NoEquipementIntervention); model.Field(field => field.NoReference).DefaultValue("Test"); model.Field(field => field.DateIntervention).DefaultValue(System.DateTime.Now); }) .Read(read => read.Action("Read", "Equipements", new { id = Model.EquipementId })) .Create(create => create.Action("Create", "Equipements", new { id = Model.EquipementId })) .Update(update => update.Action("Update", "Equipements")) .Destroy(destroy => destroy.Action("Destroy", "Equipements")) ))I try to set a default value when I add a new item in my grid. Even with a hard coded value like "Test". I have the same situation with a DateTime? field until I remove the ?. Any idea about the NoReference (string) field?
The model :
[Key]public Guid NoId { get; set; }[Required]public string NoReference { get; set; }[UIHint("Date")][Required]public DateTime DateIntervention { get; set; }
The Grid :
THANK A LOT TO EVERYONE.
