@(Html.EJ().Grid<PersonNamesViewModel>("PersonNamesGrid")
.DataManagerID("dmPersonNames")
.Query("ej.Query().addParams('personId'," + @Model.PersonId + ")")
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().RowPosition(RowPosition.Bottom).ShowDeleteConfirmDialog(); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Add);
});
})
.AllowTextWrap()
.TextWrapSettings(wrap => { wrap.WrapMode(WrapMode.Header); })
.Columns(col =>
{
col.Field(p => p.Id).IsPrimaryKey(true).IsIdentity(true).Visible(false).Add();
col.Field(p => p.PersonId).Visible(false).DefaultValue(Model.PersonId).Add();
col.Field(p => p.LastName).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].LastName).ToString()).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field(p => p.FirstName).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].FirstName).ToString()).ValidationRules(v => v.AddRule("required", true)).Add();
col.Field(p => p.OtherName).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].OtherName).ToString()).Add();
col.Field(p => p.IsPreferred).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].IsPreferred).ToString()).DisplayAsCheckbox().EditType(EditingType.Boolean).Width(80).Add();
col.Field(p => p.NameCodeId)
.HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].NameCodeId).ToString())
.ForeignKeyField("Value")
.ForeignKeyValue("Text")
.DataSource(Model.NameCodes.ToList())
.Width(100).Add();
col.Field(p => p.BirthDate).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].BirthDate).ToString()).EditType(EditingType.Datepicker).Format("{0:dd/MM/yyyy}").Width(100).Add();
col.Field(p => p.Age).HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].Age).ToString()).Width(50).Add();
col.Field(p => p.GenderCodeId)
.HeaderText(@Html.DisplayNameFor(model => model.personNamesViewModel[0].GenderCodeDescription).ToString())
.ForeignKeyField("Value")
.ForeignKeyValue("Text")
.DataSource(Model.GenderCodes.ToList())
.Width(75).Add();
col.HeaderText("Actions").Commands(commands =>
{
commands.Type(UnboundType.Edit).ButtonOptions(new ButtonProperties()
{
ContentType = ContentType.ImageOnly,
PrefixIcon = "e-icon e-edit"
}).Add();
commands.Type(UnboundType.Delete).ButtonOptions(new ButtonProperties()
{
ContentType = ContentType.ImageOnly,
PrefixIcon = "e-icon e-delete"
}).Add();
commands.Type(UnboundType.Save).ButtonOptions(new ButtonProperties()
{
ContentType = ContentType.ImageOnly,
PrefixIcon = "e-icon e-save"
}).Add();
commands.Type(UnboundType.Cancel).ButtonOptions(new ButtonProperties()
{
ContentType = ContentType.ImageOnly,
PrefixIcon = "e-icon e-cancel"
}).Add();
}).Width(150).Add();
})
.ClientSideEvents(e => { e.Create("onCreate").ActionBegin("onBegin").BeginEdit("onBeginEdit").ActionComplete("onComplete"); })
)
@(Html.EJ().Grid<object>("Grid")
.Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.dataSource).UpdateURL("CellEditUpdate").InsertURL("CellEditInsert").RemoveURL("CellEditDelete").Adaptor(AdaptorType.RemoteSaveAdaptor))
.AllowPaging()
.EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
.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);
});
})
.Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add();
col.Field("CustomerID").HeaderText("Customer ID").Add();
col.Field("OrderDate").HeaderText("Order Date").EditType(EditingType.Datepicker).ValidationRules(v => v.AddRule("required",true)).Format("{0:dd/MM/yyyy}").Add();
col.Field("ShipCity").HeaderText("Ship City").Add();
col.Field("ShipCountry").HeaderText("Ship Country").Add();
}))
|
new Date
constructor, which behaves very differently across browsers and locales. We have prepared a work around sample to meet your requirement in DatePicker validation by using add method of jQuery validation.