Skip to content

Commit fdf7e63

Browse files
committed
Grid Editing: Add a date property and date and time columns, with custom templates. Actually editing doesn't work, yet.
1 parent a2d5b5f commit fdf7e63

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

grid-editing/grid.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<link rel="stylesheet" href="../themes/base/jquery.ui.all.css">
77
<link rel="stylesheet" href="../grid-spf/grid.css">
88
<script src="../jquery-1.6.2.js"></script>
9+
<script src="../external/globalize.js"></script>
910
<script src="../external/jquery.tmpl.js"></script>
1011
<script src="../external/jquery.mousewheel-3.0.4.js"></script>
1112
<script src="../ui/jquery.ui.core.js"></script>
@@ -152,6 +153,8 @@ <h2>local data source</h2>
152153
<th data-property="lastName">Last Name</th>
153154
<th data-property="country" data-editor="countrycomplete">Country</th>
154155
<th data-property="bitcoins" data-type="number" data-editor="spinner">Bitcoins</th>
156+
<th data-template="#cell-date-tmpl">Date</th>
157+
<th data-template="#cell-time-tmpl">Time</th>
155158
<th data-property="random.value" data-type="number" data-editor="randomSpinner" data-editor-options='{"min":-1, "max": 125}'>Random</th>
156159
<th data-template="#cell-edit-tmpl">Edit</th>
157160
<th data-template="#cell-remove-tmpl">Remove</th>
@@ -181,6 +184,12 @@ <h2>local data source</h2>
181184
<input type="text" name="${name}" placeholder="${label}" value="${value}" title="${label}" />
182185
{{/if}}
183186
</script>
187+
<script id="cell-date-tmpl" type="text/x-jquery-tmpl">
188+
<td class="ui-widget-content">${Globalize.format(new Date(date), "d")}</td>
189+
</script>
190+
<script id="cell-time-tmpl" type="text/x-jquery-tmpl">
191+
<td class="ui-widget-content">${Globalize.format(new Date(date), "T")}</td>
192+
</script>
184193
<script id="cell-edit-tmpl" type="text/x-jquery-tmpl">
185194
<td class="ui-widget-content"><button class='edit'>Edit</button></td>
186195
</script>

grid-spf/developers.json

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"random": {
1010
"value": 10
1111
},
12-
"favorites": [1, 2, 3]
12+
"favorites": [1, 2, 3],
13+
"date": 174351600000
1314
},
1415
{
1516
"firstName": "Scott",
@@ -21,7 +22,8 @@
2122
"random": {
2223
"value": 20
2324
},
24-
"favorites": [1, 2, 3]
25+
"favorites": [1, 2, 3],
26+
"date": 359468280000
2527
},
2628
{
2729
"firstName": "Jörn",
@@ -33,7 +35,8 @@
3335
"random": {
3436
"value": 30
3537
},
36-
"favorites": [1, 2, 3]
38+
"favorites": [1, 2, 3],
39+
"date": 455083620000
3740
},
3841
{
3942
"firstName": "Carl",
@@ -45,7 +48,8 @@
4548
"random": {
4649
"value": 40
4750
},
48-
"favorites": [1, 2, 3]
51+
"favorites": [1, 2, 3],
52+
"date": 174351700450
4953
},
5054
{
5155
"firstName": "Adam",
@@ -57,7 +61,8 @@
5761
"random": {
5862
"value": 50
5963
},
60-
"favorites": [1, 2, 3]
64+
"favorites": [1, 2, 3],
65+
"date": 358368280045
6166
},
6267
{
6368
"firstName": "Remy",
@@ -69,7 +74,8 @@
6974
"random": {
7075
"value": 60
7176
},
72-
"favorites": [1, 2, 3]
77+
"favorites": [1, 2, 3],
78+
"date": 274351715450
7379
},
7480
{
7581
"firstName": "Benjamin",
@@ -81,7 +87,8 @@
8187
"random": {
8288
"value": 70
8389
},
84-
"favorites": [1, 2, 3]
90+
"favorites": [1, 2, 3],
91+
"date": 374351715450
8592
},
8693
{
8794
"firstName": "Haymo",
@@ -93,6 +100,7 @@
93100
"random": {
94101
"value": 80
95102
},
96-
"favorites": [1, 2, 3]
103+
"favorites": [1, 2, 3],
104+
"date": 474351715450
97105
}
98106
]

0 commit comments

Comments
 (0)