forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui-grid.d.ts
3799 lines (3679 loc) · 166 KB
/
ui-grid.d.ts
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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for ui-grid
// Project: http://www.ui-grid.info/
// Definitions by: Ben Tesser <https://github.com/btesser>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
// These are very definitely preliminary. Please feel free to improve.
// Changelog:
// 8/11/2015 ui-grid v3.0.3
// Extensive plugin support added (Plugin specific API, ColumnDef, GridOptions, GridRow, Constants).
// Added docs for all existing interfaces.
// Fixed a few incorrect interfaces, updated interfaces to reflect latest version.
// Did some cleanup... Moved all plugins into their own modules
// 7/8/2015 ui-grid v3.0.0-rc.22-482dc67
// Added primary interfaces for row, column, api, grid, columnDef, and gridOptions. Needs more tests!
/// <reference path='../jquery/jquery.d.ts' />
/// <reference path='../angularjs/angular.d.ts' />
declare module uiGrid {
export interface IUiGridConstants {
LOG_DEBUG_MESSAGES: boolean;
LOG_WARN_MESSAGES: boolean;
LOG_ERROR_MESSAGES: boolean;
CUSTOM_FILTERS: RegExp;
COL_FIELD: RegExp;
MODEL_COL_FIELD: RegExp;
TOOLTIP: RegExp;
DISPLAY_CELL_TEMPLATE: RegExp;
TEMPLATE_REGEXP: RegExp;
FUNC_REGEXP: RegExp;
DOT_REGEXP: RegExp;
APOS_REGEXP: RegExp;
BRACKET_REGEXP: RegExp;
COL_CLASS_PREFIX: string;
events: {
GRID_SCROLL: string;
COLUMN_MENU_SHOWN: string;
ITEM_DRAGGING: string;
COLUMN_HEADER_CLICK: string;
};
keymap: {
TAB: number;
STRG: number;
CAPSLOCK: number;
CTRL: number;
CTRLRIGHT: number;
CTRLR: number;
SHIFT: number;
RETURN: number;
ENTER: number;
BACKSPACE: number;
BCKSP: number;
ALT: number;
ALTR: number;
ALTRIGHT: number;
SPACE: number;
WIN: number;
MAC: number;
FN: number;
PG_UP: number;
PG_DOWN: number;
UP: number;
DOWN: number;
LEFT: number;
RIGHT: number;
ESC: number;
DEL: number;
F1: number;
F2: number;
F3: number;
F4: number;
F5: number;
F6: number;
F7: number;
F8: number;
F9: number;
F10: number;
F11: number;
F12: number;
};
ASC: string;
DESC: string;
filter: {
STARTS_WITH: number;
ENDS_WITH: number;
EXACT: number;
CONTAINS: number;
GREATER_THAN: number;
GREATER_THAN_OR_EQUAL: number;
LESS_THAN: number;
LESS_THAN_OR_EQUAL: number;
NOT_EQUAL: number;
SELECT: string;
INPUT: string;
};
scrollDirection: {
UP: string;
DOWN: string;
LEFT: string;
RIGHT: string;
NONE: string;
};
aggregationTypes: {
sum: number;
count: number;
avg: number;
min: number;
max: number;
};
CURRENCY_SYMBOLS: Array<string>;
dataChange: {
ALL: string;
EDIT: string;
ROW: string;
COLUMN: string;
OPTIONS: string;
}
scrollbars: {
NEVER: number;
ALWAYS: number;
}
}
export interface IGridInstance {
/**
* adds a row header column to the grid
* @param {IColumnDef} colDef The column definition
*/
addRowHeaderColumn(colDef: IColumnDef): void;
/**
* uses the first row of data to assign colDef.type for any types not defined.
*/
assignTypes(): void;
/**
* Populates columnDefs from the provided data
* @param {IRowBuilder} rowBuilder function to be called
*/
buildColumnDefsFromData(rowBuilder: IRowBuilder): void;
/**
* creates GridColumn objects from the columnDefinition.
* Calls each registered columnBuilder to further process the column
* @param {IBuildColumnsOptions} options An object containing options to use when building columns
* * orderByColumnDefs: defaults to false. When true, buildColumns will order existing columns
* according to the order within the column definitions
* @returns {ng.IPromise} A promise to load any needed column resources
*/
buildColumns(options: IBuildColumnsOptions): ng.IPromise<any>;
/**
* calls each styleComputation function
*/
buildStyles(): void;
/**
* Calls the callbacks based on the type of data change that has occurred.
* Always calls the ALL callbacks, calls the ROW, EDIT, COLUMN and OPTIONS callbacks
* if the event type is matching, or if the type is ALL.
* @param {number} type the type of event that occurred - one of the uiGridConstants.dataChange values
* (ALL, ROW, EDIT, COLUMN, OPTIONS
*/
callDataChangeCallbacks(type: number): void;
/**
* Clears all filters and optionally refreshes the visible rows.
* @param {boolean} [refreshRows=true] Refresh the rows?
* @param {boolean} [clearConditions=true] Clear conditions?
* @param {boolean} [clearFlags=true] Clear flags?
* @returns {ng.IPromise<any>} If refreshRows is true, returns a promise of the rows refreshing
*/
clearAllFilters(refreshRows: boolean, clearConditions: boolean,
clearFlags: boolean): ng.IPromise<any>;
/**
* refreshes the grid when a column refresh is notified, which triggers handling of the visible flag.
* This is called on uiGridConstants.dataChange.COLUMN, and is registered as a dataChangeCallback in grid.js
* @param {string} name column name
*/
columnRefreshCallback(name: string): void;
/**
* creates the left render container if it doesn't already exist
*/
createLeftContainer(): void;
/**
* creates the right render container if it doesn't already exist
*/
createRightContainer(): void;
/**
* sets isScrollingHorizontally to true and sets it to false in a debounced function
*/
flagScrollingHorizontally(): void;
/**
* sets isScrollingVertically to true and sets it to false in a debounced function
*/
flagScrollingVertically(): void;
/**
* Gets the displayed value of a cell after applying any the cellFilter
* @param {IGridRow} row Row to access
* @param {IGridColumn} col Column to access
* @returns {string} Cell display value
*/
getCellDisplayValue(row: IGridRow, col: IGridColumn): string;
/**
* Gets the displayed value of a cell
* @param {IGridRow} row Row to access
* @param {IGridColumn} col Column to access
* @returns {any} Cell value
*/
getCellValue(row: IGridRow, col: IGridColumn): any;
/**
* returns a grid colDef for the column name
* @param {string} name Column name
* @returns {IColumnDef} The column definition
*/
getColDef(name: string): IColumnDef;
/**
* returns a grid column by name
* @param {string} name Column name
* @returns {IGridColumn} The column
*/
getColumn(name: string): IGridColumn;
/**
* Return the columns that the grid is currently being sorted by
* @returns {Array<IGridColumn>} the columns that the grid is currently being sorted by
*/
getColumnSorting(): Array<IGridColumn>;
/**
* Returns the $parse-able accessor for a column within its $scope
* @param {IGridColumn} col Column object
* @returns {string} $parse-able accessor for a column within its $scope
*/
getGridQualifiedColField(col: IGridColumn): string;
/**
* returns all columns except for rowHeader columns
* @returns {Array<IGridColumn>} All data columns
*/
getOnlyDataColumns(): Array<IGridColumn>;
/**
* returns the GridRow that contains the rowEntity
* @param {any} rowEntity the gridOptionms.data array element instance
* @param {Array<IGridRow>} rows The rows to look in. if not provided then it looks in grid.rows
*/
getRow(rowEntity: any, rows?: Array<IGridRow>): IGridRow;
/**
* Triggered when the browser window resizes; automatically resizes the grid
* @param {ng.IAngularEvent} $event Resize event
*/
handleWindowResize($event: ng.IAngularEvent): void;
/**
* returns true if leftContainer exists
* @returns {boolean} container exists?
*/
hasLeftContainer(): boolean;
/**
* returns true if rightContainer exists
* @returns {boolean} container exists?
*/
hasRightContainer(): boolean;
/**
* returns true if leftContainer has columns
* @returns {boolean} container has columns
*/
hasLeftContainerColumns(): boolean;
/**
* returns true if rightContainer has columns
* @returns {boolean} container has columns
*/
hasRightContainerColumns(): boolean;
/**
* Is grid right to left
* @returns {boolean} true if grid is RTL
*/
isRTL(): boolean;
/**
* Checks if column is a row header
* @param {IGridColumn} column The column
* @returns {boolean} true if the column is a row header
*/
isRowHeaderColumn(column: IGridColumn): boolean;
/**
* creates or removes GridRow objects from the newRawData array. Calls each registered
* rowBuilder to further process the row
*
* This method aims to achieve three things:
* 1. the resulting rows array is in the same order as the newRawData, we'll call
* rowsProcessors immediately after to sort the data anyway
* 2. if we have row hashing available, we try to use the rowHash to find the row
* 3. no memory leaks - rows that are no longer in newRawData need to be garbage collected
*
* The basic logic flow makes use of the newRawData, oldRows and oldHash, and creates
* the newRows and newHash
*
* Rows are identified using the hashKey if configured. If not configured, then rows
* are identified using the gridOptions.rowEquality function
* @param {Array<any>} newRawData The new grid data
* @return {ng.IPromise<any>} Promise which resolves when the rows have been created or removed
*/
modifyRows(newRawData: Array<any>): ng.IPromise<any>;
/**
* Notify the grid that a data or config change has occurred,
* where that change isn't something the grid was otherwise noticing. This
* might be particularly relevant where you've changed values within the data
* and you'd like cell classes to be re-evaluated, or changed config within
* the columnDef and you'd like headerCellClasses to be re-evaluated.
* @param {string} type one of the uiGridConstants.dataChange values [ALL, ROW, EDIT, COLUMN], which tells
* us which refreshes to fire
*/
notifyDataChange(type: string): void;
/**
* precompiles all cell templates
*/
precompileCellTemplates(): void;
/**
* processes all RowBuilders for the gridRow
* @param {IGridRow} gridRow reference to gridRow
* @returns {IGridRow} the gridRow with all additional behavior added
*/
processRowBuilders(gridRow: IGridRow): IGridRow;
/**
* calls the row processors, specifically
* intended to reset the sorting when an edit is called,
* registered as a dataChangeCallback on uiGridConstants.dataChange.EDIT
* @param {string} name column name
*/
processRowsCallback(name: string): void;
/**
* queues a grid refresh, a way of debouncing all the refreshes we might otherwise issue
*/
queueGridRefresh(): void;
/**
* queues a grid refreshCanvas, a way of debouncing all the refreshes we might otherwise issue
*/
queueRefresh(): void;
/**
* Redraw the rows and columns based on our current scroll position
* @param {boolean} [rowsAdded] Optional to indicate rows are added and the scroll percentage must be
* recalculated
*/
redrawCanvas(rowsAdded?: boolean): void;
/**
* Refresh the rendered grid on screen.
* The refresh method re-runs both the columnProcessors and the
* rowProcessors, as well as calling refreshCanvas to update all
* the grid sizing. In general you should prefer to use queueGridRefresh
* instead, which is basically a debounced version of refresh.
*
* If you only want to resize the grid, not regenerate all the rows
* and columns, you should consider directly calling refreshCanvas instead.
* @param {boolean} rowsAltered Optional flag for refreshing when the number of rows has changed
*/
refresh(rowsAltered?: boolean): void;
/**
* Builds all styles and recalculates much of the grid sizing
* @param {boolean} buildStyles optional parameter. Use TBD
* @returns {ng.IPromise<any>} promise that is resolved when the canvas
* has been refreshed
*/
refreshCanvas(buildStyles?: boolean): ng.IPromise<any>;
/**
* Refresh the rendered rows on screen? Note: not functional at present
* @returns {ng.IPromise<any>} promise that is resolved when render completes?
*/
refreshRows(): ng.IPromise<any>;
/**
* When the build creates columns from column definitions, the columnbuilders will be called to add
* additional properties to the column.
* @param {IColumnBuilder} columnBuilder function to be called
*/
registerColumnBuilder(columnBuilder: IColumnBuilder): void;
/**
* Register a "columns processor" function. When the columns are updated,
* the grid calls each registered "columns processor", which has a chance
* to alter the set of columns, as long as the count is not modified.
* @param {IColumnProcessor} columnProcessor column processor function, which
* is run in the context of the grid (i.e. this for the function will be the grid), and
* which must return an updated renderedColumnsToProcess which can be passed to the next processor
* in the chain
* @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
* for other people to inject columns processors at intermediate priorities.
* Lower priority columnsProcessors run earlier.priority
*/
registerColumnsProcessor(columnProcessor: IColumnProcessor, priority: number): void;
/**
* When a data change occurs, the data change callbacks of the specified type
* will be called. The rules are:
*
* - when the data watch fires, that is considered a ROW change (the data watch only notices
* added or removed rows)
* - when the api is called to inform us of a change, the declared type of that change is used
* - when a cell edit completes, the EDIT callbacks are triggered
* - when the columnDef watch fires, the COLUMN callbacks are triggered
* - when the options watch fires, the OPTIONS callbacks are triggered
*
* For a given event:
* - ALL calls ROW, EDIT, COLUMN, OPTIONS and ALL callbacks
* - ROW calls ROW and ALL callbacks
* - EDIT calls EDIT and ALL callbacks
* - COLUMN calls COLUMN and ALL callbacks
* - OPTIONS calls OPTIONS and ALL callbacks
*
* @param {(grid: IGridInstance) => void} callback function to be called
* @param {Array<string>} types the types of data change you want to be informed of. Values from
* the uiGridConstants.dataChange values ( ALL, EDIT, ROW, COLUMN, OPTIONS ). Optional and defaults to
* ALL
* @returns {Function} deregister function - a function that can be called to deregister this callback
*/
registerDataChangeCallback(callback: (grid: IGridInstance) => void, types: Array<string>): Function;
/**
* When the build creates rows from gridOptions.data, the rowBuilders will be called to add
* additional properties to the row.
* @param {IRowBuilder} rowBuilder Function to be called
*/
registerRowBuilder(rowBuilder: IRowBuilder): void;
/**
* Register a "rows processor" function. When the rows are updated,
* the grid calls each registered "rows processor", which has a chance
* to alter the set of rows (sorting, etc) as long as the count is not
* modified.
*
* @param {IRowProcessor} rowProcessor rows processor function, which
* is run in the context of the grid (i.e. this for the function will be the grid), and must
* return the updated rows list, which is passed to the next processor in the chain
* @param {number} priority the priority of this processor.
* In general we try to do them in 100s to leave room for other people to inject rows processors at
* intermediate priorities. Lower priority rowsProcessors run earlier. At present all rows visible
* is running at 50, filter is running at 100, sort is at 200, grouping at 400, selectable rows at
* 500, pagination at 900 (pagination will generally want to be last)
*/
registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void;
/**
* registered a styleComputation function
*
* If the function returns a value it will be appended into the grid's `<style>` block
* @param {IStyleComputation} styleComputation function
*/
registerStyleComputation(styleComputation: ($scope: ng.IScope) => string): void;
/**
* Remove a registered rows processor
* @param {IRowProcessor} rows processor function
*/
removeRowsProcessor(rows: IRowProcessor): void;
/**
* Return the columns that the grid is currently being sorted by
* @param {IGridColumn} [excludedColumn] Optional GridColumn to exclude from having its sorting reset
*/
resetColumnSorting(excludedColumn: IGridColumn): void;
/**
* Scroll the grid such that the specified
* row and column is in view
* @param {any} rowEntity gridOptions.data[] array instance to make visible
* @param {IColumnDef} colDef to make visible
* @returns {ng.IPromise<any>} a promise that is resolved after any scrolling is finished
*/
scrollTo(rowEntity?: any, colDef?: IColumnDef): ng.IPromise<any>;
/**
* Scrolls the grid to make a certain row and column combo visible,
* in the case that it is not completely visible on the screen already.
* @param {IGridRow} gridRow row to make visible
* @param {IGridColumn} gridCol column to make visible
* @returns {ng.IPromise<any>} a promise that is resolved when scrolling is complete
*/
scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): ng.IPromise<any>;
/**
* Set the sorting on a given column, optionally resetting any existing sorting on the Grid.
* Emits the sortChanged event whenever the sort criteria are changed.
* @param {IGridColumn} column Column to set the sorting on
* @param {uiGridConstants.ASC|uiGridConstants.DESC} [direction] Direction to sort by,
* either descending or ascending. If not provided, the column will iterate through the sort
* directions: ascending, descending, unsorted.
* @param {boolean} [add] Add this column to the sorting. If not provided or set to `false`, the Grid will
* reset any existing sorting and sort by this column only
* @returns {ng.IPromise<IGridColumn>} A resolved promise that supplies the column.
*/
sortColumn(column: IGridColumn, direction?: string, add?: boolean): ng.IPromise<IGridColumn>;
/**
* flags all render containers to update their canvas height
*/
updateCanvasHeight(): void;
/**
* recalculates the footer height,
* registered as a dataChangeCallback on uiGridConstants.dataChange.OPTIONS
* @param {string} name column name
*/
updateFooterHeightCallback(name: string): void;
/**
* reference to the application scope (the parent scope of the ui-grid element). Assigned in ui-grid controller
* use gridOptions.appScopeProvider to override the default assignment of $scope.$parent with any reference
*/
appScope?: ng.IScope;
/**
* returns the total column footer height
*/
columnFooterHeight?: number;
/**
* returns the total footer height gridFooter + columnFooter
*/
footerHeight?: number;
/**
* returns or sets grid height in pixels
*/
gridHeight?: number;
/**
* set to true when Grid is scrolling horizontally. Set to false via debounced method
*/
isScrollingHorizontally?: boolean;
/**
* set to true when Grid is scrolling vertically. Set to false via debounced method
*/
isScrollingVertically?: boolean;
/**
* set one of the uiGridConstants.scrollDirection values (UP, DOWN, LEFT, RIGHT, NONE),
* which tells us which direction we are scrolling. Set to NONE via debounced method
*/
scrollDirection?: number;
}
export interface IBuildColumnsOptions {
orderByColumnDefs?: boolean;
}
export interface IStyleComputation {
($scope: ng.IScope): string;
}
export interface IColumnBuilder {
(colDef: IColumnDef, col: IGridColumn, gridOptions: IGridOptions): void;
}
export interface IRowBuilder {
(row: IGridRow, gridOptions: IGridOptions): void;
}
export interface IRowProcessor {
(renderedRowsToProcess: Array<IGridRow>, columns: Array<IGridColumn>): Array<IGridRow>;
}
export interface IColumnProcessor {
(renderedColumnsToProcess: Array<IGridColumn>, rows: Array<IGridRow>): Array<IGridColumn>;
}
export interface IGridOptions extends cellNav.IGridOptions, edit.IGridOptions, expandable.IGridOptions,
exporter.IGridOptions, grouping.IGridOptions, importer.IGridOptions, infiniteScroll.IGridOptions,
moveColumns.IGridOptions, pagination.IGridOptions, pinning.IGridOptions, resizeColumns.IGridOptions,
rowEdit.IGridOptions, saveState.IGridOptions, selection.IGridOptions, treeBase.IGridOptions,
treeView.IGridOptions {
/**
* Default time in milliseconds to throttle aggregation calcuations, defaults to 500ms
*/
aggregationCalcThrottle?: number;
/**
* by default, the parent scope of the ui-grid element will be assigned to grid.appScope
* this property allows you to assign any reference you want to grid.appScope
*/
appScopeProvider?: ng.IScope | Object;
/**
* Array of columnDef objects. Only required property is name.
*/
columnDefs?: Array<IColumnDef>;
/**
* The height of the footer rows (column footer and grid footer) in pixels
*/
columnFooterHeight?: number;
/**
* Turn virtualization on when number of columns goes over this number, defaults to 10
* @default 10
*/
columnVirtualizationThreshold?: number;
/**
* (mandatory) Array of data to be rendered into the grid, providing the data source or data binding for
* the grid.
*
* Most commonly the data is an array of objects, where each object has a number of attributes.
* Each attribute automatically becomes a column in your grid. This array could, for example, be sourced from
* an angularJS $resource query request. The array can also contain complex objects, refer the binding tutorial
* for examples of that.
*
* The most flexible usage is to set your data on $scope:
*
* `$scope.data = data;`
*
* And then direct the grid to resolve whatever is in $scope.data:
*
* `$scope.gridOptions.data = 'data';`
*
* This is the most flexible approach as it allows you to replace $scope.data whenever you feel like it without
* getting pointer issues.
*
* Alternatively you can directly set the data array:
*
* `$scope.gridOptions.data = [ ];`
* or
*
* `$http.get('/data/100.json')
* .success(function(data) {
* $scope.myData = data;
* $scope.gridOptions.data = $scope.myData;
* });`
*
* Where you do this, you need to take care in updating the data - you can't just update `$scope.myData` to some
* other array, you need to update $scope.gridOptions.data to point to that new array as well.
*/
data?: Array<any> | string;
/**
* True by default. When enabled, this setting displays a column
* menu within each column.
* @default true
*/
enableColumnMenus?: boolean;
/**
* False by default. When enabled, this setting adds filter
* boxes to each column header, allowing filtering within the column for the entire grid.
* Filtering can then be disabled on individual columns using the columnDefs.
* @default false
*/
enableFiltering?: boolean;
/**
* uiGridConstants.scrollbars.ALWAYS by default. This settings controls the horizontal scrollbar for the grid.
* Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER
* @default 1
*/
enableHorizontalScrollbar?: boolean | number;
/**
* True by default. When enabled, a newly initialized grid will check to see if it is tall enough to display
* at least one row of data. If the grid is not tall enough, it will resize the DOM element to display
* minRowsToShow number of rows.
* @default true
*/
enableMinHeightCheck?: boolean;
/**
* True by default. When enabled, this setting allows uiGrid to add
* `$$hashKey`-type properties (similar to Angular) to elements in the `data` array. This allows
* the grid to maintain state while vastly speeding up the process of altering `data` by
* adding/moving/removing rows.
*
* Note that this DOES add properties to your data that you may not want, but they are stripped out when
* using `angular.toJson()`. IF you do not want this at all you can disable this setting but you will take a
* performance hit if you are using large numbers of rows
* and are altering the data set often.
* @default true
*/
enableRowHashing?: boolean;
/**
* True by default. When enabled, this setting adds sort
* widgets to the column headers, allowing sorting of the data for the entire grid.
* Sorting can then be disabled on individual columns using the columnDefs.
* @default true
*/
enableSorting?: boolean;
/**
* uiGridConstants.scrollbars.ALWAYS by default. This settings controls the vertical scrollbar for the grid.
* Supported values: uiGridConstants.scrollbars.ALWAYS, uiGridConstants.scrollbars.NEVER
* @default 1
*/
enableVerticalScrollbar?: boolean | number;
/**
* Extra columns to to render outside of the viewport, which helps with smoothness of scrolling.
* Defaults to 4
* @default 4
*/
excessColumns?: number;
/**
* Extra rows to to render outside of the viewport, which helps with smoothness of scrolling.
* Defaults to 4
* @default 4
*/
excessRows?: number;
/**
* Array of property names in data to ignore when auto-generating column names. Provides the
* inverse of columnDefs - columnDefs is a list of columns to include, excludeProperties is a list of columns
* to exclude.
*
* If columnDefs is defined, this will be ignored.
*
* Defaults to ['$$hashKey']
*/
excludeProperties?: Array<string>;
/**
* Set to true if your columns are all related directly to fields in a flat object structure - i.e.
* each of your columns associate directly with a propery one each of the entities in your data array.
*
* In that situation we can avoid all the logic associated with complex binding to functions or to properties
* of sub-objects, which can provide a significant speed improvement with large data sets, with filtering and
* with sorting.
*
* By default false
* @default false
*/
flatEntityAccess?: boolean;
/**
* (optional) ui-grid/ui-grid-footer by default. This footer shows the per-column
* aggregation totals.
* When provided, this setting uses a custom footer template. Can be set to either the name of a template
* file 'footer_template.html', inline html
* <pre>'<div class="ui-grid-bottom-panel" style="text-align: center">I am a Custom Grid Footer</div>'</pre>,
* or the id of a precompiled template (TBD how to use this). Refer to the custom footer tutorial for more
* information.
* @default 'ui-grid/ui-grid-footer'
*/
footerTemplate?: string;
/**
* (optional) ui-grid/ui-grid-grid-footer by default. This template by default shows the
* total items at the bottom of the grid, and the selected items if selection is enabled.
* @default 'ui-grid/ui-grid-grid-footer'
*/
gridFooterTemplate?: string
/**
* Null by default. When provided, this setting uses a custom header
* template, rather than the default template. Can be set to either the name of a template file:
* <pre> $scope.gridOptions.headerTemplate = 'header_template.html';</pre>
* inline html
* <pre> $scope.gridOptions.headerTemplate = '<div class="ui-grid-top-panel" style="text-align: center">
* I am a Custom Grid Header</div>'</pre>
* or the id of a precompiled template (TBD how to use this).
* </br>Refer to the custom header tutorial for more information.
* If you want no header at all, you can set to an empty div:
* <pre> $scope.gridOptions.headerTemplate = '<div></div>';</pre>
*
* If you want to only have a static header, then you can set to static content. If
* you want to tailor the existing column headers, then you should look at the
* current 'ui-grid-header.html' template in github as your starting point.
* @default null
*/
headerTemplate?: string;
/**
* Defaults to 4
* @default 4
*/
horizontalScrollThreshold?: number;
/**
* Defaults to 200
* @default 200
*/
maxVisibleColumnCount?: number;
/**
* Minimum number of rows to show when the grid doesn't have a defined height. Defaults to "10".
* @default 10
*/
minRowsToShow?: number;
/**
* Columns can't be smaller than this, defaults to 10 pixels
* @default 10
*/
minimumColumnSize?: number;
/**
* A callback that returns the gridApi once the grid is instantiated, which is
* then used to interact with the grid programatically.
*
* Note that the gridApi.core.renderingComplete event is identical to this
* callback, but has the advantage that it can be called from multiple places
* if needed
* @param {IGridApi} gridApi
*/
onRegisterApi?: (gridApi: IGridApi) => void;
/**
* The height of the row in pixels, defaults to 30
* @default 30
*/
rowHeight?: number;
/**
* 'ui-grid/ui-grid-row' by default. When provided, this setting uses a
* custom row template. Can be set to either the name of a template file:
* <pre> $scope.gridOptions.rowTemplate = 'row_template.html';</pre>
* inline html
* <pre> $scope.gridOptions.rowTemplate =
* '<div style="background-color: aquamarine"
* ng-click="grid.appScope.fnOne(row)"
* ng-repeat="col in colContainer.renderedColumns track by col.colDef.name"
* class="ui-grid-cell" ui-grid-cell></div>';</pre>
* or the id of a precompiled template (TBD how to use this) can be provided.
* </br>Refer to the custom row template tutorial for more information.
* @default 'ui-grid/ui-grid-row'
*/
rowTemplate?: string;
/**
* Default time in milliseconds to debounce scroll events, defaults to 300ms
* @default 300
*/
scrollDebounce?: number;
/**
* Defaults to 4
* @default 4
*/
scrollThreshold?: number;
/**
* Whether or not to show the column footer, defaults to false
* The column footer displays column aggregates
* @default false
*/
showColumnFooter?: boolean;
/**
* Whether or not to show the footer, defaults to false
* The footer display Total Rows and Visible Rows (filtered rows)
* @default false
*/
showGridFooter?: boolean;
/**
* True by default. When set to false, this setting will replace the
* standard header template with '<div></div>', resulting in no header being shown.
* @default true
*/
showHeader?: boolean;
/**
* Turn virtualization on when number of data elements goes over this number, defaults to 20
* @default 20
*/
virtualizationThreshold?: number;
/**
* Default time in milliseconds to throttle scroll events to, defaults to 70ms
* @default 70
*/
wheelScrollThrottle?: number;
/**
* This function returns the identity value uniquely identifying this row,
* if one is not present it does not set it.
*
* By default it returns the `$$hashKey` property but can be overridden to use any property
* or set of properties you want.
* @param {IGridRow} row The row for which you want the unique id
* @returns {string} row uid
*/
getRowIdentity?(row: IGridRow): any;
/**
* By default, rows are compared using object equality. This option can be overridden
* to compare on any data item property or function
* @param {IGridRow} entityA First Data Item to compare
* @param {IGridRow} entityB Second Data Item to compare
*/
rowEquality?(entityA: IGridRow, entityB: IGridRow): boolean;
/**
* This function is used to get and, if necessary, set the value uniquely identifying this row
* (i.e. if an identity is not present it will set one).
*
* By default it returns the `$$hashKey` property if it exists. If it doesn't it uses gridUtil.nextUid()
* to generate one
*/
rowIdentity?(): any;
}
export interface IGridCoreApi {
// Methods
/**
* adds a row header column to the grid
* @param {IColumnDef} column Column Definition
*/
addRowHeaderColumn(column: IColumnDef): void;
/**
* add items to the grid menu. Used by features
* to add their menu items if they are enabled, can also be used by
* end users to add menu items. This method has the advantage of allowing
* remove again, which can simplify management of which items are included
* in the menu when. (Noting that in most cases the shown and active functions
* provide a better way to handle visibility of menu items)
* @param {IGridInstance} grid the grid on which we are acting
* @param {Array<IMenuItem>} items menu items in the format as described in the tutorial, with
* the added note that if you want to use remove you must also specify an `id` field,
* which is provided when you want to remove an item. The id should be unique.
*/
addToGridMenu(grid: IGridInstance, items: Array<IMenuItem>): void;
/**
* Clears all filters and optionally refreshes the visible rows.
* @param {boolean} [refreshRows=true] Defaults to true.
* @param {boolean} [clearConditions=false] Defaults to false.
* @param {boolean} [clearFlags=false] Defaults to false.
* @returns {ng.IPromise<any>} If `refreshRows` is true, returns a promise of the rows refreshing.
*/
clearAllFilters(refreshRows?: boolean, clearConditions?: boolean,
clearFlags?: boolean): ng.IPromise<Array<IGridRow>>;
/**
* Clears any override on visibility for the row so that it returns to
* using normal filtering and other visibility calculations.
* If the row is currently invisible then sets it to visible and calls
* both grid refresh and emits the rowsVisibleChanged event
* TODO: if a filter is active then we can't just set it to visible?
* @param {any} rowEntity gridOptions.data[] array instance
*/
clearRowInvisible(rowEntity: any): void;
/**
* Returns all visible rows
* @param {IGridInstance} grid the grid you want to get visible rows from
* @returns {Array<IGridRow>} an array of gridRow
*/
getVisibleRows(grid: IGridInstance): Array<IGridRow>;
/**
* Trigger a grid resize, normally this would be picked
* up by a watch on window size, but in some circumstances it is necessary
* to call this manually
* @returns {ng.IPromise<any>} promise that is resolved when render completes?
*/
handleWindowResize(): void;
/**
* Notify the grid that a data or config change has occurred,
* where that change isn't something the grid was otherwise noticing. This
* might be particularly relevant where you've changed values within the data
* and you'd like cell classes to be re-evaluated, or changed config within
* the columnDef and you'd like headerCellClasses to be re-evaluated.
* @param {string} type one of the
* uiGridConstants.dataChange values (ALL, ROW, EDIT, COLUMN), which tells
* us which refreshes to fire.
*/
notifyDataChange(type: string): void;
/**
* Refresh the rendered rows on screen? Note: not functional at present
* @returns {ng.IPromise<any>} promise that is resolved when render completes?
*/
refreshRows(): ng.IPromise<boolean>;
/**
* Register a "columns processor" function. When the columns are updated,
* the grid calls each registered "columns processor", which has a chance
* to alter the set of columns as long as the count is not
* modified.
*
* @param {IColumnProcessor} processorFunction columns processor function, which
* is run in the context of the grid (i.e. this for the function will be the grid), and must
* return the updated columns list, which is passed to the next processor in the chain
* @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
* for other people to inject columns processors at intermediate priorities. Lower priority
* columnsProcessors run earlier.
*
* At present allRowsVisible is running at 50, filter is running at 100, sort is at 200, grouping at 400,
* selectable rows at 500, pagination at 900 (pagination will generally want to be last)
*/
registerColumnsProcessor(processorFunction: IColumnProcessor, priority: number): void;
/**
* Register a "rows processor" function. When the rows are updated,
* the grid calls each registered "rows processor", which has a chance
* to alter the set of rows (sorting, etc) as long as the count is not
* modified.
*
* @param {IRowProcessor} rowProcessor rows processor function, which
* is run in the context of the grid (i.e. this for the function will be the grid), and must
* return the updated rows list, which is passed to the next processor in the chain
* @param {number} priority the priority of this processor. In general we try to do them in 100s to leave room
* for other people to inject rows processors at intermediate priorities. Lower priority rowsProcessors
* run earlier.
*
* At present all rows visible is running at 50, filter is running at 100, sort is at 200, grouping at 400,
* selectable rows at 500, pagination at 900 (pagination will generally want to be last)
*/
registerRowsProcessor(rowProcessor: IRowProcessor, priority: number): void;
/**
* Scroll the grid such that the specified
* row and column is in view
* @param {any} entity gridOptions.data[] array instance to make visible
* @param {IColumnDef} colDef to make visible
* @returns {ng.IPromise<any>} a promise that is resolved after any scrolling is finished
*/
scrollTo(entity: any, colDef: IColumnDef): void; /*A row entity can be anything?*/
/**
* Scrolls the grid to make a certain row and column combo visible,
* in the case that it is not completely visible on the screen already.
* @param {IGridRow} gridRow row to make visible
* @param {IGridColumn} gridCol column to make visible
* @returns {ng.IPromise<any>} a promise that is resolved when scrolling is complete
*/
scrollToIfNecessary(gridRow: IGridRow, gridCol: IGridColumn): void;
/**
* A null handling method that can be used when building custom sort
* functions
* @param {any} a Sort value a
* @param {any} b Sort value b
* @returns {number} null if there were no nulls/undefineds, otherwise returns
* a sort value that should be passed back from the sort function
*/
sortHandleNulls(a: any, b: any): number;
/**
* queues a grid refresh, a way of debouncing all the refreshes we might otherwise issue
*/
queueGridRefresh(): void;
/**
* queues a grid refreshCanvas, a way of debouncing all the refreshes we might otherwise issue
*/
queueRefresh(): void;
// Events
on: {
/**
* is raised when the canvas height has changed
* @param {ng.IScope} scope Grid scope
* @param {canvasHeightChangedHandler} handler Callback
*/
canvasHeightChanged: (scope: ng.IScope, handler: canvasHeightChangedHandler) => void;
/**
* The visibility of a column has changed, the column itself is passed out as a parameter of the event
* @param {ng.IScope} scope The scope of the controller. This is used to deregister this event when the
* scope is destroyed
* @param {columnVisibilityChangedHandler} callBack Will be called when the event is emited.
* The function passes back the GridCol that has changed
*/
columnVisibilityChanged: (scope: ng.IScope, callBack: columnVisibilityChangedHandler) => void;
/**
* is raised after the filter is changed.
* The nature of the watch expression doesn't allow notification of what changed,
* so the receiver of this event will need to re-extract the filter conditions from the columns.
* @param {ng.IScope} scope Grid scope
* @param {filterChangedHandler} handler Callback
*/
filterChanged: (scope: ng.IScope, handler: filterChangedHandler) => void;
/**
* is raised after the cache of visible rows is changed
* @param {ng.IScope} scope Grid scope
* @param {rowsRenderedHandler} handler callback
*/
rowsRendered: (scope: ng.IScope, handler: rowsRenderedHandler) => void;
/**
* is raised after the rows that are visible change.
* The filtering is zero-based, so it isn't possible to say which rows changed
* (unlike in the selection feature). We can plausibly know which row was changed when setRowInvisible is
* called, but in that situation the user already knows which row they changed.
* When a filter runs we don't know what changed, and that is the one that would have been useful.
* @param {ng.IScope} scope Grid scope
* @param {rowsVisibleChangedHandler} handler callback
*/
rowsVisibleChanged: (scope: ng.IScope, handler: rowsVisibleChangedHandler) => void;