Skip to main content

MVCxGridViewEditingSettings.AddNewRowRouteValues Property

Defines the callback routing logic by specifying the names of a Controller and an Action which should handle callbacks related to adding a new row.

Namespace: DevExpress.Web.Mvc

Assembly: DevExpress.Web.Mvc5.v24.1.dll

NuGet Package: DevExpress.Web.Mvc5

Declaration

public object AddNewRowRouteValues { get; set; }

Property Value

Type Description
Object

An object containing the Controller and Action names.

Property Paths

You can access this nested property as listed below:

Object Type Path to AddNewRowRouteValues
GridViewSettings
.SettingsEditing .AddNewRowRouteValues
MVCxGridView
.SettingsEditing .AddNewRowRouteValues
MVCxGridViewProperties
.SettingsEditing .AddNewRowRouteValues

Remarks

If row insertion is allowed for GridView, you should provide an associated controller action that will apply insert operations to a Model and return the grid’s partial view. Use the AddNewRowRouteValues property to reference this controller action by its name and the name of its controller.

Note that in an action that handles delete operations, you can obtain the key value of the deleted row.

View (‘InlineEditingPartial’):

<%
    var grid = Html.DevExpress().GridView(
        settings =>
        {
            settings.Name = "gvEditing";
            settings.KeyFieldName = "ProductID";
            settings.CallbackRouteValues = new { Controller = "GridView", Action = "InlineEditingPartial" };
            ...
            settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "GridView", Action = "InlineEditingAddNewPartial" };
            ...
    grid.Bind(Model).Render();
%>

Controller (‘GridViewController’):

public partial class GridViewController : Controller {
        ...
        public ActionResult InlineEditingPartial() {
            return PartialView("InlineEditingPartial", NorthwindDataProvider.GetEditableProducts());
        }
        ...
        [HttpPost]
        public ActionResult InlineEditingAddNewPartial([ModelBinder(typeof(DevExpressEditorsBinder))] EditableProduct product) {
            if(ModelState.IsValid) {
                try {
                    NorthwindDataProvider.UpdateProduct(product);
                }
                catch(Exception e) {
                    ViewData["EditError"] = e.Message;
                }
            }
            else
                ViewData["EditError"] = "Please, correct all errors.";
            return PartialView("InlineEditingPartial", NorthwindDataProvider.GetEditableProducts());
        }
        ...
See Also