FlexGrid
FlexGrid
Empty Editing
This page demos how to use CommitEmptyEdits property.
Features
ID
Country
Product
Amount
Active
History
ID
Country
Product
Amount
Active
History
1
German
Gadget
2680
72,81,76,55,20,55,90
2
China
Gadget
-578
72,81,76,55,20,55,90,44
3
UK
Widget
1327
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99,67,31,81,84
4
Gadget
4953
72,81,76,55,20,55,90,44,97
5
Italy
Gadget
4919
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3
6
China
Gadget
1876
72,81,76,55
7
US
Widget
-2028
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98
8
German
Widget
-1190
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99,67,31,81,84
9
China
Gadget
-3810
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99,67,31,81
10
German
Widget
-428
72,81,76,55,20,55,90
11
Japan
Gadget
1198
72,81,76,55,20,55
12
Italy
Gadget
2354
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3
13
France
Widget
3954
72,81,76,55
14
Italy
Widget
1441
72,81,76,55,20,55,90
15
Korea
Widget
1522
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99,67
16
US
Gadget
2185
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99,67,31,81
17
US
Widget
408
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3
18
Japan
Gadget
3092
72,81,76,55,20,55,90,44,97,27,29,46,63,46,98,3,86,99
19
Korea
Widget
228
72,81,76,55,20,55,90,44,97
20
UK
Gadget
-2775
72,81,76,55
0
Items Changed:
Settings
CommitEmptyEdits: True
Description
If you choose to ignore commit empty edits, the Grid will not commit empty edits to cell values if the original value is null.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | using C1.Web.Mvc; using System; using System.Linq; using C1.Web.Mvc.Serialization; using Microsoft.AspNetCore.Mvc; using MvcExplorer.Models; using System.Data.SqlClient; using Microsoft.EntityFrameworkCore; using System.Collections.Generic; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { private static IDictionary< string , object []> _getClientSettings() { return new Dictionary< string , object []> { { "CommitEmptyEdits" , new object []{ true , false }} }; } private static IDictionary< string , object > _getDefaultValues() { var defaultValues = new Dictionary< string , object > { { "CommitEmptyEdits" , true } }; return defaultValues; } private static List<Sale> _sourceSale = Sale.GetDataContainNull(20).ToList<Sale>(); public ActionResult EmptyEditing() { ViewBag.DemoSettings = true ; ViewBag.DemoSettingsModel = new ClientSettingsModel { Settings = _getClientSettings(), DefaultValues = _getDefaultValues() }; return View(_sourceSale); } public ActionResult EmptyEditing_Data() { ViewBag.DemoSettings = true ; ViewBag.DemoSettingsModel = new ClientSettingsModel { Settings = _getClientSettings(), DefaultValues = _getDefaultValues() }; return View(_sourceSale); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | @model IEnumerable< Sale > @ { ClientSettingsModel demoSettingsModel = ViewBag.DemoSettingsModel; ViewBag.DemoDescription = true ; } @section Scripts{ <script> var editGrid, editCV, cvDetail; c1.documentReady( function () { editGrid = wijmo.Control.getControl( '#DemoControl' ); editCV = editGrid.collectionView; if (editCV){ editCV.trackChanges = true ; editCV.itemsEdited.collectionChanged.addHandler(updateResult); } }); function updateResult(s, e) { var result = document.getElementById( "result" ); var line = "Country: " + getValue(e.item[ "Country" ]) + ", Product: " + getValue(e.item[ "Product" ]) + ", Amount: " + getValue(e.item[ "Amount" ]); result.innerHTML += "<br />" + line; } function getValue(val) { if (val != null ) return "<b>" + val + "</b>" ; return "<b>Null</b>" ; } </script> } @section Summary{ @Html .Raw(FlexGridRes.EmptyEdit_Text0) } < c1-items-source id = "CVService" source-collection = "@Model" > </ c1-items-source > < c1-flex-grid id = "DemoControl" items-source-id = "CVService" auto-generate-columns = "false" allow-add-new = "true" auto-row-heights = "true" allow-delete = "true" refresh-on-edit = "false" show-placeholders = "true" style = "height:400px" > < c1-flex-grid-column binding = "ID" is-read-only = "true" format = "d" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Country" is-required = "false" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Product" width = "*" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Amount" format = "d" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Active" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "History" ></ c1-flex-grid-column > < c1-items-source source-collection = "@Model" > </ c1-items-source > </ c1-flex-grid > < h4 > @Html .Raw(FlexGridRes.EmptyEdit_Text2) </ h4 > < div id = "result" style = "line-height:22px;font-size:13px;overflow-y:scroll;height:115px;" > </ div > @section Description{ < h4 > @Html .Raw(FlexGridRes.EmptyEdit_Text1) </ h4 > } |