Skip to content

Latest commit

 

History

History
65 lines (50 loc) · 4.21 KB

File metadata and controls

65 lines (50 loc) · 4.21 KB

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

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)