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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
|
<link rel='import' href='vaadin-grid.html'>
<!-- Object for controlling and accessing the columns in the grid. -->
<dom-module id="Column"></dom-module>
<script>
Polymer({
is: 'Column',
properties: {
/**
* Name of the column.
* Must be a valid JS variable name so that the same name can be used in
* the data source object fields.
*/
name: String,
/**
* Content of the column in the default header row object.
*
* Attribute: `header-text`
*/
headerContent: String,
/**
* Enables sorting the data in the column by the end user.
*
* Attribute: `sortable`
*
* @property {boolean} sortable
* @type {boolean}
* @default false
*/
sortable: false,
/**
* Minimum width of the column in pixels.
*
* Attribute: `min-width`
*
* @property {number} minWidth
* @type {number}
* @default 10
*/
minWidth: Number,
/**
* Maximum width of the column in pixels.
*
* Attribute: `max-width`
*/
maxWidth: Number,
/**
* Width of the column in pixels.
*
* Attribute: `width`
*/
width: Number,
/**
* Flex ratio of the column (expand ratio in Vaadin-speak). Uses integers.
*
* Attribute: `flex`
*
* @property {number} flex
* @type {number}
* @default -1
*/
flex: Number,
/**
* Custom renderer function for the columns data items.
*
* Example:
* ```
* column.renderer = function(cell) {
* cell.element.innerHTML = '$' + cell.data;
* };
* ```
* @property {function} renderer
* @param {Cell} cell - Reference to the cell being rendered.
* @type {function}
*/
renderer: function(cell) {},
/**
* Set whether it is possible for the user to hide this column or not.
*
* Attribute: `hidable`
*
* @property {boolean} hidable
* @type {boolean}
* @default false
*/
hidable: false,
/**
* Hides or shows the column. By default columns are visible before
* explicitly hiding them.
*
* Attribute: `hidden`
*
* @property {boolean} hidden
* @type {boolean}
* @default false
*/
hidden: false,
/**
* Sets the hiding toggle's caption for this column. Shown in the toggle
* for this column in the grid's sidebar when the column is hidable.
*
* Attribute: `hiding-toggle-text`
*
* @property {String} hidingToggleText
* @type {String}
*/
hidingToggleText: String
}
});
</script>
<!--
Object for accessing and controlling data source used in the grid.
-->
<dom-module id="Data"></dom-module>
<script>
Polymer({
is: 'Data',
properties: {
/**
* Data source for the grid.
*
* If an array is used, it is wrapped with a function internally.
* Reading the property value will still return the array. *
*
* Example:
* ```
* data.source = [
* ["horse", 150, "domestic"],
* ["wolf", 100, "wild"]
* };
* ```
* or
* ```
* var myArray = [...];
* data.source = function(req) {
* var from = req.index;
* var to = req.index + req.count;
* var array = myArray.slice(from, to);
*
* req.success(array, data.length);
* };
* ```
*
* Params:
* - {DataRequest} req – Reference to the DataRequest object
*
* @property {Array|Function} source
* @type {Array|Function}
*/
source: Object,
/**
* Order of sorting.
*
* @property {Array<SortOrder>} source
* @type {Array<SortOrder>}
*/
sortOrder: Array,
/**
* Clears the cache.
*
* @type {Function}
*/
clearCache: Function,
/**
* Invokes the callback with row data of the provided row index as the
* parameter. If the row is not cached, it's fetched from the data source
* first.
*
* @method getItem
* @param {number} rowIndex - Index of the row.
* @param {Function} callback - Gets arguments (err, item) where item is the desired data item.
* @param {boolean} onlyCached - Only fetch cached rows (don't fall back to data source request).
*/
getItem: Function
}
});
</script>
<!--
Object used to request data from the data source.
-->
<dom-module id="DataRequest"></dom-module>
<script>
Polymer({
is: 'DataRequest',
properties: {
/**
* Index of the first data item to fetch.
*/
index: Number,
/**
* Number of data items to fetch.
*/
count: Number,
/**
* Sorting order of the fetched data items.
*
* @property {Array<SortOrder>} sortOrder
* @type {Array<SortOrder>}
* */
sortOrder: Object
},
/**
* Callback function to pass along the data items to the grid and the total size of the data source.
*
* Example:
* ```
* var myArray = [...];
*
* var from = req.index;
* var to = req.index + req.count;
* var array = myArray.slice(from, to);
*
* req.success(array, data.length);
* ```
*
* @method success
* @param {Array<*>} items - Fetched data items.
* @param {number} totalSize – Total quantity of the data items.
*/
success: function(items, totalSize) {},
/**
* Callback function to inform the grid that something failed while getting the data.
*
* Example:
* ```
* req.failure();
* ```
*
* @method failure
*/
failure: function() {}
});
</script>
<!--
Object for accessing and controlling footer rows.
-->
<dom-module id="Footer"></dom-module>
<script>
Polymer({
is: 'Footer',
properties: {
/**
* Hides all footers in the grid.
*
* @property {boolean} hidden
* @default false
* @type {boolean}
*/
hidden: Boolean,
/**
* Number of rows in the footer.
*
* @property {number} rowCount
* @type {number}
*/
rowCount: Number
},
/**
* Adds a new footer row.
*
* @method addRow
* @param {number} index - Index of the new footer row. If undefined, it is inserted as the last row.
*/
addRow: function(index) {},
/**
* Removes a specific footer row.
*
* @method removeRow
* @param {number} index - Index of the row to be removed.
*/
removeRow: function(index) {},
/**
* Returns an object reference to a particular footer cell.
*
* @method getCell
* @param {number} rowIndex - Index of the row.
* @param {number|string} column - Index or name of the column.
* @return {StaticCell} An object reference to a particular footer cell
*/
getCell: function(rowIndex, column) {},
/**
* Sets the class name for a footer row.
*
* @method setRowClassName
* @param {number} rowIndex - Index of the row.
* @param {string} className - New class name
*/
setRowClassName: function(rowIndex, className) {}
});
</script>
<!--
Object for accessing and controlling header rows.
-->
<dom-module id="Header"></dom-module>
<script>
Polymer({
is: 'Header',
properties: {
/**
* Hides all headers in the grid.
*
* @property {boolean} hidden
* @default false
* @type {boolean}
*/
hidden: Boolean,
/**
* Index of the default header row if multiple header rows exist.
*
* @property {number} defaultRow
* @type {number}
*/
defaultRow: Number,
/**
* Number of rows in the header.
*
* @property {number} rowCount
* @type {number}
*/
rowCount: Number
},
/**
* Adds a new header row.
*
* @method addRow
* @param {number} index - Index of the new header row. If undefined, it is inserted as the last row.
*/
addRow: function(index) {},
/**
* Removes a specific header row.
*
* @method removeRow
* @param {number} index - Index of the row to be removed.
*/
removeRow: function(index) {},
/**
* Returns an object reference to a particular header cell.
*
* @method getCell
* @param {number} rowIndex - Index of the row.
* @param {number|string} column - Index or name of the column.
* @return {StaticCell} An object reference to a particular header cell
*/
getCell: function(rowIndex, column) {},
/**
* Sets the class name for a header row.
*
* @method setRowClassName
* @param {number} rowIndex - Index of the row.
* @param {string} className - New class name
*/
setRowClassName: function(rowIndex, className) {}
});
</script>
<!--
Object referencing to a row and it's data.
-->
<dom-module id="Row"></dom-module>
<script>
Polymer({
is: 'Row',
properties: {
/**
* Index of the row.
*/
index: Number,
/**
* Data object of the row.
*
* @property {*} data
* @type {*}
*/
data: Object,
/**
* Reference to the <vaadin-grid> element
*
* @property {HTMLElement} grid
* @type {HTMLElement}
*/
grid: Object,
/**
* Reference to the TR element
*
* @property {HTMLElement} element
* @type {HTMLElement}
*/
element: Object
}
});
</script>
<!--
Object for accessing and controlling selected rows of the grid.
-->
<dom-module id="Selection"></dom-module>
<script>
Polymer({
is: 'Selection',
properties: {
/**
* Mode of the selection.
*
* Attribute: `selection-mode`
*
* @property {"single"|"multi"|"all"|"disabled"} mode
* @type {"single"|"multi"|"all"|"disabled"}
*/
mode: String,
/**
* Size of the selection.
*/
size: Number
},
/**
* Selects a row.
*
* @method select
* @param {number} index – Index of the row.
*/
select: function(index) {},
/**
* Deselects a row.
*
* @method deselect
* @param {number} index – Index of the row.
*/
deselect: function(index) {},
/**
* Clears the selection.
*
* @method clear
*/
clear: function() {},
/**
* Selects all rows.
*
* @method selectAll
*/
selectAll: function() {},
/**
* Selected row indexes.
*
* @method selected
* @return {Array<number>} Indexes of the selected rows.
*/
selected: function() {},
/**
* Deselected row indexes.
*
* @method deselected
* @return {Array<number>} Indexes of the deselected rows.
*/
deselected: function() {}
});
</script>
<!--
Object for defining the sorting order of the columns.
-->
<dom-module id="SortOrder"></dom-module>
<script>
Polymer({
is: 'SortOrder',
properties: {
/**
* Sort direction.
*
* Attribute: `sort-direction`
*
* @property {string} direction
* @default "asc"
* @type {string}
*/
direction: String,
/**
* Index of the column.
*/
column: Number
}
});
</script>
<!--
Represents a grid header/footer cell configuration.
-->
<dom-module id="StaticCell"></dom-module>
<script>
Polymer({
is: 'StaticCell',
properties: {
/**
* Class name of the cell.
*/
className: String,
/**
* Contents of the cell.
*/
content: Object,
/**
* Number of columns which the cell should span/group.
*
* @default 0
*/
colspan: Number
}
});
</script>
<!--
Object referencing to a cell and it's data.
-->
<dom-module id="Cell"></dom-module>
<script>
Polymer({
is: 'Cell',
properties: {
/**
* Column name of the cell.
*/
columnName: String,
/**
* HTML element of the cell.
*
* @property {HTMLElement} element
* @type {HTMLElement}
*/
element: Object,
/**
* Parent row of the cell.
*
* @property {Row} row
* @type {Row}
*/
row: Object,
/**
* Contents of the cell.
*/
data: Object,
/**
* Column index of the cell.
*/
index: Number
}
});
</script>
|