This example demonstrates how to specify the grid's edit form template for newly inserted rows.
Handle the grid's client-side BeginCallback event to determine the grid's edit mode after a callback.
function OnBeginCallback(s, e) {
var isNewRowNow = s.IsNewRowEditing();
var isSwitchToNewRow = (e.command == 'ADDNEWROW');
var IsCancelEdit = (e.command == 'CANCELEDIT');
var IsSwitchToEdit = (e.command == 'STARTEDIT');
var result = (isSwitchToNewRow * !IsCancelEdit + isNewRowNow) * !IsSwitchToEdit;
e.customArgs['IsNewRow'] = Boolean(result);
}Process the received value in the Controller and use the ViewBag mechanism to pass the value to the View.
[HttpPost, ValidateInput(false)]
public ActionResult GridViewEditingPartial(bool IsNewRow) {
if (IsNewRow)
ViewBag.IsNewRow = true;
return PartialView(list.GetPersons());
}
[HttpPost, ValidateInput(false)]
public ActionResult EditingAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Person person) {
ViewBag.IsNewRow = true;
// ...
}Call the grid's SetEditFormTemplateContent method to create an edit form template based on the ViewBag value.
if(ViewBag.IsNewRow != null)
if(ViewBag.IsNewRow == true)
settings.SetEditFormTemplateContent(c => {
ViewContext.Writer.Write("EditForm Template Content");
});(you will be redirected to DevExpress.com to submit your response)
