forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ng-table.d.ts
838 lines (777 loc) · 35.8 KB
/
ng-table.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
// Type definitions for ng-table
// Project: https://github.com/esvit/ng-table
// Definitions by: Christian Crowhurst <https://github.com/christianacca>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
/**
* Parameters manager for an ngTable directive
*/
declare class NgTableParams<T> {
/**
* The page of data rows currently being displayed in the table
*/
data: T[];
constructor(baseParameters?: NgTable.IParamValues<T>, baseSettings?: NgTable.ISettings<T>)
/**
* Returns the number of data rows per page
*/
count(): number
/**
* Sets the number of data rows per page.
* Changes to count will cause `isDataReloadRequired` to return true
*/
count(count: number): NgTableParams<T>
/**
* Returns the current filter values used to restrict the set of data rows.
* @param trim supply true to return the current filter minus any insignificant values
* (null, undefined and empty string)
*/
filter(trim?: boolean): NgTable.IFilterValues
/**
* Sets filter values to the `filter` supplied; any existing filter will be removed
* Changes to filter will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
*/
filter(filter: NgTable.IFilterValues): NgTableParams<T>
/**
* Generate array of pages.
* When no arguments supplied, the current parameter state of this `NgTableParams` instance will be used
*/
generatePagesArray(currentPage?: number, totalItems?: number, pageSize?: number, maxBlocks?: number): NgTable.IPageButton[]
/**
* Returns the current grouping used to group the data rows
*/
group(): NgTable.Grouping<T>
/**
* Sets grouping to the `field` and `sortDirection` supplied; any existing grouping will be removed
* Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
*/
group(field: string, sortDirection?: string): NgTableParams<T>
/**
* Sets grouping to the `group` supplied; any existing grouping will be removed.
* Changes to group will cause `isDataReloadRequired` to return true and the current `page` to be set to 1
*/
group(group: NgTable.Grouping<T>): NgTableParams<T>
/**
* Returns true when an attempt to `reload` the current `parameter` values have resulted in a failure.
* This method will continue to return true until the `reload` is successfully called or when the
* `parameter` values have changed
*/
hasErrorState(): boolean
/**
* Returns true if `filter` has significant filter value(s) (any value except null, undefined, or empty string),
* otherwise false
*/
hasFilter(): boolean
/**
* Return true when a change to `filters` require the `reload` method
* to be run so as to ensure the data presented to the user reflects these filters
*/
hasFilterChanges(): boolean
/**
* Returns true when at least one group has been set
*/
hasGroup(): boolean
/**
* Returns true when the `group` and when supplied, the `sortDirection` matches an existing group
*/
hasGroup(group: string | NgTable.IGroupingFunc<T>, sortDirection?: string): boolean
/**
* Return true when a change to this instance should require the `reload` method
* to be run so as to ensure the data rows presented to the user reflects the current state.
*
* Note that this method will return false when the `reload` method has run but fails. In this case
* `hasErrorState` will return true.
*
* The built-in `ngTable` directives will watch for when this function returns true and will then call
* the `reload` method to load its data rows
*/
isDataReloadRequired(): boolean
/**
* Returns sorting values in a format that can be consumed by the angular `$orderBy` filter service
*/
orderBy(): string[]
/**
* Trigger a reload of the data rows
*/
reload<TResult extends NgTable.Data.DataResult<T>>(): ng.IPromise<TResult[]>
/**
* Returns the settings for the table.
*/
settings(): NgTable.ISettings<T>
/**
* Sets the settings for the table; new setting values will be merged with the existing settings.
* Supplying a new `dataset` will cause `isDataReloadRequired` to return true and the `ngTableEventsChannel`
* to fire its `datasetChanged` event
*/
settings(newSettings: NgTable.ISettings<T>): NgTableParams<T>
/**
* Returns the current sorting used to order the data rows.
* Changes to sorting will cause `isDataReloadRequired` to return true
*/
sorting(): NgTable.ISortingValues
/**
* Sets sorting values to the `sorting` supplied; any existing sorting will be removed.
* Changes to sorting will cause `isDataReloadRequired` to return true
*/
sorting(sorting: NgTable.ISortingValues): NgTableParams<T>
/**
* Sets sorting to the `field` and `direction` supplied; any existing sorting will be removed
*/
sorting(field: string, direction: string): NgTableParams<T>
/**
* Returns the index of the current "slice" of data rows
*/
page(): number
/**
* Sets the index of the current "slice" of data rows. The index starts at 1.
* Changing the page number will cause `isDataReloadRequired` to return true
*/
page(page: number): NgTableParams<T>
/**
* Returns the count of the data rows that match the current `filter`
*/
total(): number
/**
* Sets `settings().total` to the value supplied.
* Typically you will need to set a `total` in the body of any custom `getData` function
* you supply as a setting value to this instance.
* @example
* var tp = new NgTableParams({}, { getData: customGetData })
* function customGetData(params) {
* var queryResult = /* code to fetch current data rows and total *\/
* params.total(queryResult.total);
* return queryResult.dataRowsPage;
* }
*/
total(total: number): NgTableParams<T>
/**
* Returns the current parameter values uri-encoded. Set `asString` to
* true for the parameters to be returned as an array of strings of the form 'paramName=value'
* otherwise parameters returned as a key-value object
*/
url(asString?: boolean): { [name: string]: string } | string[]
}
declare namespace NgTable {
interface IDataSettings {
applyPaging?: boolean;
}
/**
* An angular value object that allow for overriding of the initial default values used when constructing
* an instance of `NgTableParams`
*/
interface IDefaults {
params?: IParamValues<any>;
settings?: ISettings<any>
}
/**
* Map of the names of fields declared on a data row and the corrosponding filter value
*/
interface IFilterValues { [name: string]: any }
/**
* Map of the names of fields on a data row and the corrosponding sort direction;
* Set the value of a key to undefined to let value of `ISettings.defaultSort` apply
*/
interface ISortingValues { [name: string]: string }
type Grouping<T> = IGroupValues | IGroupingFunc<T>;
/**
* Map of the names of fields on a data row and the corrosponding sort direction
*/
interface IGroupValues { [name: string]: string }
/**
* Signature of a function that should return the name of the group
* that the `item` should be placed within
*/
interface IGroupingFunc<T> {
(item: T): string;
/**
* 'asc' or 'desc'; leave undefined to let the value of `ISettings.groupOptions.defaultSort` apply
*/
sortDirection?: string
}
/**
* The runtime values for `NgTableParams` that determine the set of data rows and
* how they are to be displayed in a table
*/
interface IParamValues<T> {
/**
* The index of the "slice" of data rows, starting at 1, to be displayed by the table.
*/
page?: number;
/**
* The number of data rows per page
*/
count?: number;
/**
* The filter that should be applied to restrict the set of data rows
*/
filter?: IFilterValues;
/**
* The sort order that should be applied to the data rows.
*/
sorting?: ISortingValues;
/**
* The grouping that should be applied to the data rows
*/
group?: string | Grouping<T>;
}
type FilterComparator<T> = boolean | IFilterComparatorFunc<T>;
interface IFilterComparatorFunc<T> {
(actual: T, expected: T): boolean;
}
interface IFilterFunc<T> {
(data: T[], filter: IFilterValues, filterComparator: FilterComparator<T>): T[]
}
interface IFilterSettings<T> {
/**
* Use this to determine how items are matched against the filter values.
* This setting is identical to the `comparator` parameter supported by the angular
* `$filter` filter service
*
* Defaults to `undefined` which will result in a case insensitive susbstring match when
* `IDefaultGetData` service is supplying the implementation for the
* `ISettings.getData` function
*/
filterComparator?: FilterComparator<T>;
/**
* A duration to wait for the user to stop typing before applying the filter.
* - Defaults to 0 for small managed inmemory arrays ie where a `ISettings.dataset` argument is
* supplied to `NgTableParams.settings`.
* - Defaults to 500 milliseconds otherwise.
*/
filterDelay?: number;
/**
* The number of elements up to which a managed inmemory array is considered small. Defaults to 10000.
*/
filterDelayThreshold?: number;
/**
* Overrides `IDefaultGetDataProvider.filterFilterName`.
* The value supplied should be the name of the angular `$filter` service that will be selected to perform
* the actual filter logic.
* Defaults to 'filter'.
*/
filterFilterName?: string;
/**
* Tells `IDefaultGetData` to use this function supplied to perform the filtering instead of selecting an angular $filter.
*/
filterFn?: IFilterFunc<T>;
/**
* The layout to use when multiple html templates are to rendered in a single table header column.
* Available values:
* - stack (the default)
* - horizontal
*/
filterLayout?: string
}
interface IGroupSettings {
/**
* The default sort direction that will be used whenever a group is supplied that
* does not define its own sort direction
*/
defaultSort?: string;
/**
* Determines whether groups should be displayed expanded to show their items. Defaults to true
*/
isExpanded?: boolean;
}
/**
* Definition of the buttons rendered by the data row pager directive
*/
interface IPageButton {
type: string;
number?: number;
active: boolean;
current?: boolean;
}
/**
* Configuration settings for `NgTableParams`
*/
interface ISettings<T> {
/**
* Returns true whenever a call to `getData` is in progress
*/
$loading?: boolean;
/**
* An array that contains all the data rows that NgTable should manage.
* The `gateData` function will be used to manage the data rows
* that ultimately will be displayed.
*/
dataset?: T[];
dataOptions?: {};
/**
* The total number of data rows before paging has been applied.
* Typically you will not need to supply this yourself
*/
total?: number;
/**
* The default sort direction that will be used whenever a sorting is supplied that
* does not define its own sort direction
*/
defaultSort?: string;
filterOptions?: IFilterSettings<T>;
groupOptions?: IGroupSettings;
/**
* The page size buttons that should be displayed. Each value defined in the array
* determines the possible values that can be supplied to `NgTableParams.page()`
*/
counts?: number[];
/**
* The collection of interceptors that should apply to the results of a call to
* the `getData` function before the data rows are displayed in the table
*/
interceptors?: IInterceptor<T>[];
/**
* Configuration for the template that will display the page size buttons
*/
paginationMaxBlocks?: number;
/**
* Configuration for the template that will display the page size buttons
*/
paginationMinBlocks?: number;
/**
* The html tag that will be used to display the sorting indicator in the table header
*/
sortingIndicator?: string;
/**
* The function that will be used fetch data rows. Leave undefined to let the `IDefaultGetData`
* service provide a default implementation that will work with the `dataset` array you supply.
*
* Typically you will supply a custom function when you need to execute filtering, paging and sorting
* on the server
*/
getData?: Data.IGetDataFunc<T> | Data.IInterceptableGetDataFunc<T>;
/**
* The function that will be used group data rows according to the groupings returned by `NgTableParams.group()`
*/
getGroups?: Data.IGetGroupFunc<T>;
}
/**
* Configuration values that determine the behaviour of the `ngTableFilterConfig` service
*/
interface IFilterConfigValues {
/**
* The default base url to use when deriving the url for a filter template given just an alias name
* Defaults to 'ng-table/filters/'
*/
defaultBaseUrl?: string;
/**
* The extension to use when deriving the url of a filter template when given just an alias name
*/
defaultExt?: string;
/**
* A map of alias names and their corrosponding urls. A lookup against this map will be used
* to find the url matching an alias name.
* If no match is found then a url will be derived using the following pattern `${defaultBaseUrl}${aliasName}.${defaultExt}`
*/
aliasUrls?: { [name: string]: string };
}
/**
* The angular provider used to configure the behaviour of the `ngTableFilterConfig` service
*/
interface IFilterConfigProvider {
$get: IFilterConfig;
/**
* Reset back to factory defaults the config values that `ngTableFilterConfig` service will use
*/
resetConfigs(): void;
/**
* Set the config values used by `ngTableFilterConfig` service
*/
setConfig(customConfig: IFilterConfigValues): void;
}
/**
* A key value-pair map where the key is the name of a field in a data row and the value is the definition
* for the template used to render a filter cell in the header of a html table.
* Where the value is supplied as a string this should either be url to a html template or an alias to a url registered
* using the `ngTableFilterConfigProvider`
* @example
* vm.ageFilter = { "age": "number" }
* @example
* vm.ageFilter = { "age": "my/custom/ageTemplate.html" }
* @example
* vm.ageFilter = { "age": { id: "number", placeholder: "Age of person"} }
*/
interface IFilterTemplateDefMap {
[name: string]: string | IFilterTemplateDef
}
/**
* A fully qualified template definition for a single filter
*/
interface IFilterTemplateDef {
/**
* A url to a html template of an alias to a url registered using the `ngTableFilterConfigProvider`
*/
id: string,
/**
* The text that should be rendered as a prompt to assist the user when entering a filter value
*/
placeholder: string
}
/**
* Exposes configuration values and methods used to return the location of the html
* templates used to render the filter row of an ng-table directive
*/
interface IFilterConfig {
/**
* Readonly copy of the final values used to configure the service.
*/
config: IFilterConfigValues,
/**
* Return the url of the html filter template for the supplied definition and key.
* For more information see the documentation for `IFilterTemplateMap`
*/
getTemplateUrl(filterDef: string | IFilterTemplateDef, filterKey?: string): string,
/**
* Return the url of the html filter template registered with the alias supplied
*/
getUrlForAlias(aliasName: string, filterKey?: string): string
}
interface InternalTableParams<T> extends NgTableParams<T> {
isNullInstance: boolean
}
/**
* A custom object that can be registered with an NgTableParams instance that can be used
* to post-process the results (and failures) returned by its `getData` function
*/
interface IInterceptor<T> {
response?: <TData>(data: TData, params: NgTableParams<T>) => TData;
responseError?: (reason: any, params: NgTableParams<T>) => any;
}
type SelectData = ISelectOption[] | ISelectDataFunc
interface ISelectOption {
id: string | number;
title: string;
}
interface ISelectDataFunc {
(): ISelectOption[] | ng.IPromise<ISelectOption[]>
}
/**
* Definition of the constructor function that will construct new instances of `NgTableParams`.
* On construction of `NgTableParams` the `ngTableEventsChannel` will fire its `afterCreated` event.
*/
interface ITableParamsConstructor<T> {
new (baseParameters?: IParamValues<T>, baseSettings?: ISettings<T>): NgTableParams<T>
}
namespace Data {
type DataResult<T> = T | IDataRowGroup<T>;
interface IDataRowGroup<T> {
data: T[];
$hideRows: boolean;
value: string;
}
/**
* A default implementation of the getData function that will apply the `filter`, `orderBy` and
* paging values from the `NgTableParams` instance supplied to the data array supplied.
*
* A call to this function will:
* - return the resulting array
* - assign the total item count after filtering to the `total` of the `NgTableParams` instance supplied
*/
interface IDefaultGetData<T> {
(data: T[], params: NgTableParams<T>): T[];
/**
* Convenience function that this service will use to apply paging to the data rows.
*
* Returns a slice of rows from the `data` array supplied and sets the `NgTableParams.total()`
* on the `params` instance supplied to `data.length`
*/
applyPaging(data: T[], params: NgTableParams<T>): T[],
/**
* Returns a reference to the function that this service will use to filter data rows
*/
getFilterFn(params: NgTableParams<T>): IFilterFunc<T>,
/**
* Returns a reference to the function that this service will use to sort data rows
*/
getOrderByFn(params?: NgTableParams<T>): void
}
/**
* Allows for the configuration of the ngTableDefaultGetData service.
*/
interface IDefaultGetDataProvider {
$get<T>(): IDefaultGetData<T>;
/**
* The name of a angular filter that knows how to apply the values returned by
* `NgTableParams.filter()` to restrict an array of data.
* (defaults to the angular `filter` filter service)
*/
filterFilterName: string,
/**
* The name of a angular filter that knows how to apply the values returned by
* `NgTableParams.orderBy()` to sort an array of data.
* (defaults to the angular `orderBy` filter service)
*/
sortingFilterName: string
}
interface IGetDataBcShimFunc<T> {
(originalFunc: ILegacyGetDataFunc<T>): { (params: NgTableParams<T>): ng.IPromise<T[]> }
}
/**
* Signature of a function that will called whenever NgTable requires to load data rows
* into the table.
* `params` is the table requesting the data rows
*/
interface IGetDataFunc<T> {
(params: NgTableParams<T>): T[] | ng.IPromise<T[]>;
}
interface IGetGroupFunc<T> {
(params: NgTableParams<T>): { [name: string]: IDataRowGroup<T>[] }
}
/**
* Variation of the `IGetDataFunc` function signature that allows for flexibility for
* the shape of the return value.
* Typcially you will use this function signature when you want to configure `NgTableParams` with
* interceptors that will return the final data rows array.
*/
interface IInterceptableGetDataFunc<T> {
<TResult>(params: NgTableParams<T>): TResult;
}
interface ILegacyGetDataFunc<T> {
($defer: ng.IDeferred<T[]>, params: NgTableParams<T>): void
}
}
namespace Events {
interface IEventSelectorFunc {
(publisher: NgTableParams<any>): boolean
}
type EventSelector<T> = NgTableParams<T> | IEventSelectorFunc
interface IDatasetChangedListener<T> {
(publisher: NgTableParams<T>, newDataset: T[], oldDataset: T[]): any
}
interface IAfterCreatedListener {
(publisher: NgTableParams<any>): any
}
interface IAfterReloadDataListener<T> {
(publisher: NgTableParams<T>, newData: NgTable.Data.DataResult<T>[], oldData: NgTable.Data.DataResult<T>[]): any
}
interface IPagesChangedListener {
(publisher: NgTableParams<any>, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): any
}
interface IUnregistrationFunc {
(): void
}
interface IEventsChannel {
/**
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterCreated(listener: Events.IAfterCreatedListener, scope: ng.IScope, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new `NgTableParams` instance has finished being constructed.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterCreated(listener: Events.IAfterCreatedListener, eventFilter?: Events.IEventSelectorFunc): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterReloadData<T>(listener: Events.IAfterReloadDataListener<T>, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the `reload` method of an `NgTableParams` instance has successfully executed
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onAfterReloadData<T>(listener: Events.IAfterReloadDataListener<T>, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onDatasetChanged<T>(listener: Events.IDatasetChangedListener<T>, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever a new data rows *array* is supplied as a `settings` value to a `NgTableParams` instance.
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onDatasetChanged<T>(listener: Events.IDatasetChangedListener<T>, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called. Supply a
* `scope` to have angular automatically unregister the listener when the `scope` is destroyed.
*
* @param listener the function that will be called when the event fires
* @param scope the angular `$scope` that will limit the lifetime of the event subscription
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onPagesChanged<T>(listener: Events.IPagesChangedListener, scope: ng.IScope, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
/**
* Subscribe to receive notification whenever the paging buttons for an `NgTableParams` instance change
* Optionally supply an `eventFilter` to restrict which events that should trigger the `listener` to be called.
*
* @param listener the function that will be called when the event fires
* @param eventFilter either the specific `NgTableParams` instance you want to receive events for or a predicate function that should return true to receive the event
* @return a unregistration function that when called will unregister the `listener`
*/
onPagesChanged<T>(listener: Events.IPagesChangedListener, eventFilter?: Events.EventSelector<T>): IUnregistrationFunc;
publishAfterCreated<T>(publisher: NgTableParams<T>): void;
publishAfterReloadData<T>(publisher: NgTableParams<T>, newData: T[], oldData: T[]): void;
publishDatasetChanged<T>(publisher: NgTableParams<T>, newDataset: T[], oldDataset: T[]): void;
publishPagesChanged<T>(publisher: NgTableParams<T>, newPages: NgTable.IPageButton[], oldPages: NgTable.IPageButton[]): void;
}
}
namespace Columns {
type ColumnFieldContext = ng.IScope & {
$column: IColumnDef;
$columns: IColumnDef[];
}
interface IColumnField<T> {
(context?: ColumnFieldContext): T;
assign($scope: ng.IScope, value: T): void;
}
/**
* The definition of the column within a ngTable.
* When using `ng-table` directive a column definition will be parsed from each `td` tag found in the
* `tr` data row tag.
*
* @example
* <tr>
* <td data-title="'Name of User'" filter="{ username: 'text'}" sortable="'username'" />
* <td data-title="'Age of User'" filter="{ age: 'number'}" sortable="'age'" />
* </tr>
*/
interface IColumnDef {
/**
* Custom CSS class that should be added to the `th` tag(s) of this column in the table header
*
* To set this on the `td` tag of a html table use the attribute `header-class` or `data-header-class`
*/
class: IColumnField<string>;
/**
* The `ISelectOption`s that can be used in a html filter template for this colums.
*/
data?: SelectData;
/**
* The index position of this column within the `$columns` container array
*/
id: number;
/**
* The definition of 0 or more html filter templates that should be rendered for this column in
* the table header
*/
filter: IColumnField<IFilterTemplateDefMap>;
/**
* Supplies the `ISelectOption`s that can be used in a html filter template for this colums.
* At the creation of the `NgTableParams` this field will be called and the result then assigned
* to the `data` field of this column.
*/
filterData: IColumnField<ng.IPromise<SelectData> | SelectData>;
/**
* The name of the data row field that will be used to group on, or false when this column
* does not support grouping
*/
groupable: IColumnField<string | boolean>;
/**
* The url of a custom html template that should be used to render a table header for this column
*
* To set this on the `td` tag for a html table use the attribute `header` or `data-header`
*/
headerTemplateURL: IColumnField<string | boolean>;
/**
* The text that should be used as a tooltip for this column in the table header
*/
headerTitle: IColumnField<string>;
/**
* Determines whether this column should be displayed in the table
*
* To set this on the `td` tag for a html table use the attribute `ng-if`
*/
show: IColumnField<boolean>;
/**
* The name of the data row field that will be used to sort on, or false when this column
* does not support sorting
*/
sortable: IColumnField<string | boolean>;
/**
* The title of this column that should be displayed in the table header
*/
title: IColumnField<string>;
/**
* An alternate column title. Typically this can be used for responsive table layouts
* where the titleAlt should be used for small screen sizes
*/
titleAlt: IColumnField<string>;
}
type DynamicTableColField<T> = IDynamicTableColFieldFunc<T> | T;
interface IDynamicTableColFieldFunc<T> {
(context: ColumnFieldContext): T;
}
/**
* The definition of the column supplied to a ngTableDynamic directive.
*/
interface IDynamicTableColDef {
/**
* Custom CSS class that should be added to the `th` tag(s) of this column in the table header
*/
class?: DynamicTableColField<string>;
/**
* The definition of 0 or more html filter templates that should be rendered for this column in
* the table header
*/
filter?: DynamicTableColField<IFilterTemplateDefMap>;
/**
* Supplies the `ISelectOption`s that can be used in a html filter template for this colums.
* At the creation of the `NgTableParams` this field will be called and the result then assigned
* to the `data` field of this column.
*/
filterData?: DynamicTableColField<ng.IPromise<SelectData> | SelectData>;
/**
* The name of the data row field that will be used to group on, or false when this column
* does not support grouping
*/
groupable?: DynamicTableColField<string | boolean>;
/**
* The url of a custom html template that should be used to render a table header for this column
*/
headerTemplateURL?: DynamicTableColField<string | boolean>;
/**
* The text that should be used as a tooltip for this column in the table header
*/
headerTitle?: DynamicTableColField<string>;
/**
* Determines whether this column should be displayed in the table
*/
show?: DynamicTableColField<boolean>;
/**
* The name of the data row field that will be used to sort on, or false when this column
* does not support sorting
*/
sortable?: DynamicTableColField<string|boolean>;
/**
* The title of this column that should be displayed in the table header
*/
title?: DynamicTableColField<string>;
/**
* An alternate column title. Typically this can be used for responsive table layouts
* where the titleAlt should be used for small screen sizes
*/
titleAlt?: DynamicTableColField<string>;
}
}
}