Hello,
I have a grid with two dates and I want to edit date cells using datetimepicker.
@(Html.EJ().Grid<SlimHub.Models.ContractLocation>("ContractLocationsGrid")
.Datasource(ds => ds.Json((IEnumerable<ContractLocation>)Model.ContractLocations.ToList()).UpdateURL("../NormalContractLocationUpdate").InsertURL("../NormalContractLocationInsert").RemoveURL("../NormalContractLocationDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.EditSettings(edit =>
{
edit.AllowAdding().AllowDeleting().AllowEditing();
})
.Locale("it-IT")
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
items.AddTool(ToolBarItems.Edit);
items.AddTool(ToolBarItems.Delete);
items.AddTool(ToolBarItems.Update);
items.AddTool(ToolBarItems.Cancel);
});
})
.AllowResizing()
.AllowTextWrap(true)
.Columns(col =>
{
col.Field("Id").HeaderText("ID Riga Postazione Contratto").HeaderTextAlign(TextAlign.Center).IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
col.Field("ContractId").DefaultValue(@Model.ContractId).HeaderText("ID Contratto").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Right).Width(5).Visible(false).Add();
//col.Field("LocationId").HeaderText("Codice Postazione").ForeignKeyField("LocationId").ForeignKeyValue("LocationCode").DataSource((IEnumerable<object>)ViewBag.Locations).HeaderTextAlign(TextAlign.Center).Width(45).Add();
col.Field("LocationId").HeaderText("Codice Postazione").ForeignKeyField("LocationId").ForeignKeyValue("LocationCode").DataSource("../GetAllAvailableLocations").HeaderTextAlign(TextAlign.Center).Width(45).Add();
col.Field("StartDate").HeaderText("Data Impianto").TextAlign(TextAlign.Center).Format("{0:dd/MM/yyyy}").DefaultValue(@DateTime.Today).Width(20).Add();
col.Field("EndDate").HeaderText("Data Rimozione").TextAlign(TextAlign.Center).Format("{0:dd/MM/yyyy}").Width(20).Add();
col.Field("FlagIntExt").HeaderText("Interna").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(5).EditType(EditingType.Boolean).Add();
col.Field("PositionType").HeaderText("Tipo Posiz.").ForeignKeyField("LocationTypeId").ForeignKeyValue("LocationTypeDesc").DataSource((IEnumerable<object>)ViewBag.LocationTypes).HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(10).Add();
col.Field("FloorplanId").HeaderText("Planimetria").ForeignKeyField("FloorplanId").ForeignKeyValue("Filename").DataSource((IEnumerable<Floorplan>)@ViewBag.Floorplans).HeaderTextAlign(TextAlign.Center).Width(10).Add();
col.Field("FloorplanBookmark").HeaderText("Bookmark Planimetria").HeaderTextAlign(TextAlign.Center).TextAlign(TextAlign.Center).Width(10).Add();
})
.ClientSideEvents(eve =>
{
eve.ActionComplete("complete").ActionBegin("begin").EndEdit("endEdit").EndAdd("endAdd");
eve.RecordClick("onContractLocationRecordClick");
eve.Load("onContractLocationsGridLoad");
})
)
The problem is that the StartDate column is correctly rendered as DateTimePicker, while EndDate is rendered as a normal input text box.
The model is this:
public class ContractLocation
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
[DisplayName("ID Riga")]
public int Id { get; set; }
public int ContractId { get; set; }
[ScriptIgnore]
public virtual Contract Contract { get; set; }
public int LocationId { get; set; }
[ScriptIgnore]
public virtual Location Location { get; set; }
[DisplayName("Data Impianto")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? StartDate { get; set; }
[DisplayName("Data Rimozione")]
[DataType(DataType.DateTime)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? EndDate { get; set; }
[DisplayName("ID Planimetria")]
public int? FloorplanId { get; set; }
[DisplayName("Bookmark su Planimetria")]
public string FloorplanBookmark { get; set; }
[ScriptIgnore]
public virtual Floorplan Floorplan { get; set; }
}
What is the problem?
Thanks.
Claudio