MVCxTreeListBatchUpdateValues<T, S>.Insert Property
Contains a list of objects that are the tree list nodes added on the client side in batch edit mode.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v19.2.dll
Declaration
Property Value
Type | Description |
---|---|
List<T> | A List<T> object that stores a list of nodes that have been added on the client side. |
Remarks
In batch editing mode, all the end-user changes are maintained on the client side until the Update button is clicked, or all changes are canceled by clicking the Cancel button. When an end-user clicks Update, the tree list extension sends a callback with user changes (the MVCxTreeListBatchUpdateValues<T, S> object) to the server side. This callback is handled by an Action in the Controller, defined using the BatchUpdateRouteValues property. This Action method receives the MVCxTreeListBatchUpdateValues<T, S> object as a parameter, and allows you to apply all the changes made on the client side to the tree list’s data source.
The Insert property contains a list of nodes added on the client side in batch edit mode.
The code sample below demonstrates how to apply the changes obtained from the client side to the data source.
Controller code (“HomeController”):
namespace MyProject.Controllers
{
public class HomeController : Controller
{
// ...
// Apply all changes made on the client side to a data source.
[HttpPost, ValidateInput(false)]
public ActionResult BatchEditingUpdateModel(MVCxTreeListBatchUpdateValues<Customer, object> updateValues)
{
var model = db.Customers;
// Insert all newly added values.
foreach (var customer in updateValues.Insert)
{
if (updateValues.IsValid(customer))
{
try
{
model.Add(customer);
db.SaveChanges();
}
catch (Exception e)
{
ViewBag.EditError = e.Message;
}
}
}
// Update all edited values.
// ...
// Delete all values that were deleted on the client side from the data source.
// ...
return PartialView("_TreeListPartial", model.ToList());
}
}
}