FlexGrid
OData Defer Commits
The default value for this property is false, which causes any changes to the data to be immediately committed to the database.
Features
Sample
Settings
Description
The default value for this property is false, which causes any changes to the data to be immediately committed to the database.
If you set this property to true, any changes to the data (including edits, additions, and removals) will be tracked but not committed to the database until you click Commit button to commit the changes, or Cancel button to discard all pending changes
Source
ODataDeferCommitsController.cs
using C1.Web.Mvc; using C1.Web.Mvc.Serialization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; using System.Collections.Generic; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { // GET: /ODataDeferCommits/ private readonly ControlOptions _oDataDeferCommitsSetting = new ControlOptions { Options = new OptionDictionary { {"Defer Commits", new OptionItem{Values = new List<string> {"True", "False"}, CurrentValue = "False"}} } }; public ActionResult ODataDeferCommits(IFormCollection collection) { _oDataDeferCommitsSetting.LoadPostData(collection); ViewBag.DemoOptions = _oDataDeferCommitsSetting; return View(); } } }
ODataDeferCommits.cshtml
@{ ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true; } @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('@(FlexGridRes.ODataDeferCommits_Done_Text0)'); }); var isChanged = (cv.itemsEdited && cv.itemsEdited.length); if (isChanged) { setQueryMessage('@(FlexGridRes.ODataDeferCommits_Updating_Text0)'); } else { setQueryMessage('@(FlexGridRes.ODataDeferCommits_No_Change_Text0)'); } } function cancelChanges() { cv.cancelChanges(); setQueryMessage('');//clear message } function setQueryMessage(message, className) { var element = document.getElementById('queryMessage'); element.innerHTML = message; element.className = className; } </script> } <input type="button" value="Commit" class="btn" onclick="commitEdits()" /> <input type="button" value="Cancel" class="btn" onclick="cancelChanges()" /> <span id="queryMessage"></span> <c1-flex-grid id="oDataDeferCommits"> <c1-odata-source service-url="https://services.odata.org/V4/(S(3vn0jej2dr3ebcgodm1zxcys))/TripPinServiceRW/" table-name="Airlines" keys="AirlineCode" defer-commits="@(Convert.ToBoolean(optionsModel.Options["Defer Commits"].CurrentValue))"></c1-odata-source> </c1-flex-grid> @section Settings{ @await Html.PartialAsync("_OptionsMenu", optionsModel) } @section Description{ <p>@Html.Raw(FlexGridRes.ODataDeferCommits_Description_Text0)</p> <p>@Html.Raw(FlexGridRes.ODataDeferCommits_Description_Text1)</p> } @section Summary{ @Html.Raw(FlexGridRes.ODataDeferCommits_Summary_Text0) }
Documentation