Skip to content

Enable the grid's batch edit mode and use a controller action method to update grid data.

License

Notifications You must be signed in to change notification settings

DevExpress-Examples/asp-net-mvc-grid-batch-edit-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid View for ASP.NET MVC - Implement the batch edit functionality

This example demonstrates how to enable the grid's batch edit mode and use a controller action method to update grid data.

Grid in batch edit mode

Overview

In batch edit mode, the grid allows users to modify data in batches and send them to the server in one request. Set the grid's SettingsEditing.Mode property to Batch to enable the grid's batch edit functionality.

settings.SettingsEditing.Mode = GridViewEditingMode.Batch;

To enable batch edit operations, add a controller action method. This method obtains a MVCxGridViewBatchUpdateValues object as a parameter. Use the object's Update, Insert, and DeleteKeys properties to get infomation about modified, inserted, and deleted grid rows.

public ActionResult BatchEditingUpdateModelPerson(MVCxGridViewBatchUpdateValues<Person, int> batchValues) {
    foreach(var person in batchValues.Update) {
        if(batchValues.IsValid(person))
            PersonsList.UpdatePerson(person);
        else
            batchValues.SetErrorText(person, "Correct validation errors");
    }
    foreach(var person in batchValues.Insert) {
        if(batchValues.IsValid(person))
            PersonsList.AddPerson(person);
        else
            batchValues.SetErrorText(person, "Correct validation errors");
    }
    foreach (var personID in batchValues.DeleteKeys) {
        PersonsList.DeletePerson(personID);
    }
    return PartialView("GridViewPartial", PersonsList.GetPersons());
}

Files to Review

Documentation

More Examples