I have a Kendo grid which has custom edit buttons and a toolbar which allows you to add new.
The edit/new functionality uses only one template.
How can I tell if I am in 'Edit' mode vs 'New' mode.
My code(Kendo Grid):
@(Html.Kendo().Grid(Model.OtherBreeds)
.Name("grdOtherBreeds")
.HtmlAttributes(new { @class = "grid" })
.Columns(columns =>
{
columns.Bound(c => c.OrganizationName);
columns.Bound(c => c.Prefix);
columns.Bound(c => c.Name);
columns.Bound(c => c.MemberId);
columns.Template(e => { })
.ClientTemplate(KendoTemplates.ActionColumn.WithEdit().WithDelete().Get())
.Visible(true)
.Title(Resources.Actions)
.Width(Constants.GridCommandColumnWidth);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(50) //? standard page size when grid is only UI element on screen?
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.OrganizationName);
model.Field(p => p.Prefix);
model.Field(p => p.Name);
model.Field(p => p.MemberId);
})
)
.Events(e => e.DataBound(KendoEventHandlers.DataBound.WithNoData(Resources.NoOtherBreedsForCustomer).Get()))
.Sortable()
.Pageable()
.Filterable()
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("OtherBreedTemplate").Window(w => w.Width(500).Title("Add Other Breed")))
.ToolBar(toolbar =>
{
toolbar.Template(KendoTemplates.Toolbar.WithAdd("Add Other Breed").Get());
})
)
Edit
event you can capture to get the form data before the popup is shown there should be ane.model.isNew()
you can check - JamieD77