FlexGrid
FlexGrid
Preserve White Space
The sampe shows how to make the grid should keep whitespace in cells as they appear in the data or whether it should collapse the whitespace into a single space character.
Features
ID
Country
Product
Color
Amount
Amount2
ID
Country
Product
Color
Amount
Amount2
1
German
Gadget
Green
$581.61
$1,030.17
2
Italy
Gadget
Green
($4,673.75)
$3,499.71
3
China
Gadget
Black
($2,265.49)
$4,535.49
4
France
Widget
Green
$3,964.40
$432.90
5
UK
Widget
Red
($1,744.99)
$3,355.18
6
France
Gadget
Red
$4,276.37
$1,106.71
7
US
Widget
Green
($4,376.92)
$1,408.24
8
Japan
Gadget
Black
$1,996.52
$3,077.04
9
Korea
Widget
Red
($3,442.35)
$4,068.26
10
US
Widget
Green
($2,973.96)
$4,568.15
11
Canada
Widget
Green
($3,217.79)
$4,414.46
12
UK
Gadget
Red
$1,556.19
$1,705.14
13
Canada
Gadget
Red
($4,981.75)
$4,917.13
14
China
Gadget
Green
($397.56)
$1,702.41
15
Italy
Widget
Green
$199.60
$4,148.18
16
China
Gadget
Green
($176.56)
$506.04
17
Canada
Widget
Black
($542.28)
$1,471.61
18
Japan
Gadget
Red
$4,319.97
$4,562.80
19
France
Gadget
Green
($1,397.67)
$3,784.00
20
UK
Widget
Black
($3,476.95)
$4,926.25
21
UK
Gadget
Red
$3,295.03
$1,143.47
22
China
Widget
Red
($4,598.11)
$3,889.99
23
Korea
Widget
Red
($3,396.86)
$4,829.86
24
German
Widget
Green
$4,399.82
$2,594.90
25
Korea
Gadget
Red
$3,235.00
$1,183.91
26
Korea
Widget
Red
$341.60
$1,285.88
27
France
Widget
Red
$1,561.78
$4,661.58
28
German
Widget
Red
($191.55)
$812.79
29
Korea
Widget
Black
$1,516.57
$466.65
30
Italy
Gadget
Red
$4,470.85
$527.11
31
Canada
Widget
Black
$4,796.84
$1,327.69
32
France
Gadget
Black
$2,871.26
$3,139.54
33
US
Gadget
Green
($3,744.20)
$4,940.47
34
Japan
Widget
White
($2,588.21)
$914.61
35
Japan
Widget
Black
($3,709.87)
$379.20
36
German
Gadget
Green
($2,500.33)
$1,337.27
37
China
Gadget
White
$1,169.17
$2,552.76
38
UK
Widget
White
($3,578.79)
$1,080.73
39
UK
Gadget
Black
($3,175.21)
$1,174.79
40
US
Widget
Red
($2,410.67)
$3,407.91
41
UK
Widget
Black
$1,645.36
$2,607.51
42
German
Widget
Red
($38.23)
$4,135.44
43
China
Widget
White
($2,409.07)
$2,411.30
44
Korea
Gadget
Black
($1,396.05)
$115.18
45
US
Widget
White
($78.75)
$3,762.99
46
Japan
Gadget
White
($3,179.15)
$97.09
47
Japan
Widget
Green
($1,872.55)
$342.34
48
US
Widget
White
$2,186.94
$743.95
49
Canada
Widget
White
($4,924.10)
$1,601.10
50
US
Widget
Green
($3,540.61)
$4,553.11
0
loading...
Settings
Description
The sampe shows how to make the grid should keep whitespace in cells as they appear in the data or whether it should collapse the whitespace into a single space character.
When 'Preserve White Space' value is set True, the grid will keep whitespace in cells. See Color column for more clartity.
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 | using C1.Web.Mvc; using C1.Web.Mvc.Serialization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using MvcExplorer.Models; using System.Collections.Generic; using System.Linq; namespace MvcExplorer.Controllers { public partial class FlexGridController : Controller { private readonly ControlOptions _preserveWhiteSpaceDataModel = new ControlOptions { Options = new OptionDictionary { { "Preserve White Space" , new OptionItem {Values = new List< string > { "True" , "False" }, CurrentValue = "True" }} } }; public ActionResult PreserveWhiteSpace(IFormCollection collection) { _preserveWhiteSpaceDataModel.LoadPostData(collection); ViewBag.DemoOptions = _preserveWhiteSpaceDataModel; return View(); } public ActionResult PreserveWhiteSpace_Bind([C1JsonRequest] CollectionViewRequest<Sale> requestData) { var extraData = requestData.ExtraRequestData .ToDictionary(kvp => kvp.Key, kvp => new StringValues(kvp.Value.ToString())); var data = new FormCollection(extraData); _columnPinningDataModel.LoadPostData(data); var model = Sale.GetData(50).ToList(); model.ForEach(x => { if (x.Color.Equals( "Black" ) || x.Color.Equals( "White" )) { x.Color = string .Format( " {0} " , x.Color); } }); return this .C1Json(CollectionViewHelper.Read(requestData, model)); } } } |
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 | @using C1.Web.Mvc.Grid @model IEnumerable< Sale > @ { ControlOptions optionsModel = ViewBag.DemoOptions; ViewBag.DemoSettings = true ; } @section Scripts{ <script> function collectingQueryData(sender, e) { if (e.extraRequestData == null ) { e.extraRequestData = {}; } @foreach ( var menuName in optionsModel.Options.Keys.Select(ControlOptions.ToOptionName)) { < text > e.extraRequestData[ "@(menuName)" ] = '@(optionsModel.Options[menuName].CurrentValue)' ; </ text > } } </script> } < c1-flex-grid id = "ovFlexGrid" auto-generate-columns = "false" class = "grid" is-read-only = "true" preserve-white-space = "@Convert.ToBoolean(optionsModel.Options[" Preserve White Space "].CurrentValue)" > < c1-flex-grid-column binding = "ID" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Country" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Product" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Color" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Amount" format = "c" ></ c1-flex-grid-column > < c1-flex-grid-column binding = "Amount2" format = "c" ></ c1-flex-grid-column > < c1-items-source read-action-url = "@Url.Action(" PreserveWhiteSpace_Bind ")" query-data = "collectingQueryData" ></ c1-items-source > </ c1-flex-grid > @section Settings{ @await Html.PartialAsync( "_OptionsMenu" , optionsModel) } @section Summary{ < p > @Html .Raw(FlexGridRes.PreserveWhiteSpace_Text0)</ p > } @section Description{ < p > @Html .Raw(FlexGridRes.PreserveWhiteSpace_Text0)</ p > < p > @Html .Raw(FlexGridRes.PreserveWhiteSpace_Text1)</ p > } |