MVCxCardViewEditingSettings.AddNewCardRouteValues 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 card.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
Declaration
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 AddNewCardRouteValues |
---|---|
CardViewSettings |
|
MVCxCardView |
|
Remarks
If card insertion is allowed for CardView, you should provide an associated controller action that will apply insert operations to a Model and return the CardView’s partial view. Use the AddNewCardRouteValues 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 card.
View (‘CardViewPartial’):
<%
var CardView = Html.DevExpress().CardView(
settings =>
{
settings.Name = "cvEditing";
settings.KeyFieldName = "ProductID";
settings.CallbackRouteValues = new { Controller = "CardView", Action = "CardViewPartial" };
...
settings.SettingsEditing.AddNewCardRouteValues = new { Controller = "CardView", Action = "CardViewAddNewPartial" };
...
CardView.Bind(Model).Render();
%>
Controller (‘CardViewController’):
public partial class CardViewController : Controller {
...
public ActionResult CardViewPartial() {
return PartialView("CardViewPartial", NorthwindDataProvider.GetEditableProducts());
}
...
[HttpPost]
public ActionResult CardViewAddNewPartial([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("CardViewPartial", NorthwindDataProvider.GetEditableProducts());
}
...