ASP.NET MVC Controls | ComponentOne
Working with Controls / FlexGrid / Work with FlexGrid / Editing / Deferred Batch Updates
In This Topic
    Deferred Batch Updates
    In This Topic

    FlexGrid provides support for deferred batch updates through ODataCollectionViewService class which allows MVC applications to use OData data sources. It supports CRUD operations by committing changes (edits, adds, and deletes) immediately to the database.

    To defer batch updates, you can set the DeferCommits property to true. This causes the ODataCollectionView to track any changes made to the data and prevent any commits to the database until you click the Commit button to commit the changes to the database or click the Cancel button to discard the changes without committing them as shown in the following example where the code creates an ODataCollectionView with deferred commits:

    Image showing deferred batch updates

    Add Model

    Copy Code
    public partial class Category
        public int CategoryID { get; set; }
        public string CategoryName { get; set; }
        public string Description { get; set; }

    Add Controller

    Copy Code
    public ActionResult Index()
         return View();

    Add View for the Controller

    Copy Code
    @using ODataDeferCommmit_MVC.Models
    @model IEnumerable<Category>
    @section Scripts{
        <script type="text/javascript">
            var cv, oDataDeferCommits, minHeight;
            c1.documentReady(function () {
                oDataDeferCommits = wijmo.Control.getControl('#oDataDeferCommits');
                cv = oDataDeferCommits.collectionView;
            function commitEdits() {
                cv.commitChanges(function (r) {
                    setQueryMessage('Commit Done');
                var isChanged = (cv.itemsEdited && cv.itemsEdited.length);
                if (isChanged) {
                    setQueryMessage('Commit Updating');
                } else {
                    setQueryMessage('Commit NoChange');
            function cancelChanges() {
                setQueryMessage('');//clear message
            function setQueryMessage(message, className) {
                var element = document.getElementById('queryMessage');
                element.innerHTML = message;
                element.className = className;
    <input type="button" value="Commit" class="btn" onclick="commitEdits()" />
    <input type="button" value="Cancel" class="btn" onclick="cancelChanges()" />
    <span id="queryMessage"></span>
        .Columns(columns => columns
            .Add(c => c.Binding("").Header("OData Id").IsReadOnly(true))
            .Add(c => c.Binding("@odata.editLink").Header("OData edit link").IsReadOnly(true))
            .Add(c => c.Binding("AirlineCode").Header("Airline Code"))
            .Add(c => c.Binding("Name")))
        .BindODataSource(odsb =>