forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynatable.d.ts
1155 lines (1150 loc) · 37.9 KB
/
dynatable.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 jquery.dynatable v0.3.1
// Project: http://www.dynatable.com/
// Definitions by: François Massart <https://github.com/francoismassart/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface JQuery {
/**
* @constructor
*/
dynatable: JQueryDynatable.Dynatable;
}
/** Static members of jQuery (those on $ and jQuery themselves) */
interface JQueryStatic {
/**
* Global dynatable plugin setting defaults
*
* @param options The configuration options to be set globally
*/
dynatableSetup(options: JQueryDynatable.Options): void;
}
declare namespace JQueryDynatable {
interface Features {
/**
* Enable the pagination feature
*
* @default true
*/
paginate?: boolean;
/**
* Enable the sorting feature
*
* @default true
*/
sort?: boolean;
/**
* Enable the pushState feature
* Used to update the page URL parameters and cache the query result for the browser's forward- and back-buttons
*
* @default true
*/
pushState?: boolean;
/**
* Enable the search feature
*
* @default true
*/
search?: boolean;
/**
* Enable the recordCount feature
* When pagination is enabled, dynatable will also show the currently displayed records and the total number of records
*
* @default true
*/
recordCount?: boolean;
/**
* Enable the perPageSelect feature
* The perPageSelect will insert a form control filled with the options from `perPageOptions`
*
* @default true
*/
perPageSelect?: boolean;
}
interface Column {
index: number;
label: string;
/**
* Determined by the `data-dynatable-column` or using the `defaultColumnIdStyle`
*
* @example
* // Using the `defaultColumnIdStyle` of `camelCase`
* // `<th>Favorite Music</th>` would be translated into the id `favoriteMusic`
*/
id: string;
/**
* Function that returns the cell data to be written inside the cell
*
* @param record A data object representing the current line of data
* @return The data for the current cell
*
* @example
* function exampleAttributeWriter(record) {
* return record[this.id];
* };
*/
attributeWriter: (record: any) => any;
/**
* Function that interprets the cell html data in order to convert it into data
*
* @param cell A html node of the target cell
* @param record A data object representing the current line of data
* @return the html content for the current cell
*
* @example
* function exampleAttributeReader(cell, record) {
* return $(cell).html();
* };
*/
attributeReader: (cell: Element, record: any) => string;
/** List of ids for sorting, generated by the plugin, can be tweaked by using `data-dynatable-sorts` */
sorts: Array<string>;
hidden: boolean;
/**
* Detected internally by dynatable.
* Possible values are:
*
* @enum('left', 'right', 'center', 'justify', 'initial', 'inherit')
*/
textAlign: string;
}
interface Table {
/**
* By default, dynatable converts headings to JSON attribute names using:
*
* @enum('camelCase', 'trimDash', 'dashed', 'underscore', 'lowercase')
* @default 'camelCase'
* @see http://www.dynatable.com/#converting-attribute-names
*
* @example
* // Given the html `<th>Favorite Music</th>` column header
* // `camelCase` would translate it to id `favoriteMusic`
* // `trimDash` would translate it to id `Favorite-Music`
* // `dashed` would translate it to id `favorite-music`
* // `underscore` would translate it to id `favorite_music`
* // `lowercase` would translate it to id `favorite music`
*/
defaultColumnIdStyle?: string;
/** Generated internally by the plugin, will be reset by the DomColumns at init */
columns?: Array<JQueryDynatable.Column>;
/**
* Selector used by dynatable in order to find the table header row
*
* @default 'thead tr'
*/
headRowSelector?: string;
/**
* Selector used by dynatable in order to find the table body rows
*
* @default 'tbody tr'
*/
bodyRowSelector?: string;
/**
* Optional classname that can be added by dynatable to the header cells
*
* @default null
*/
headRowClass?: string;
}
interface Inputs {
/**
* Allows you to provide an array of jQuery objects which point to our filter inputs.
* The inputs musts have a name attribute value matching a columnId in order to work.
* Input values must strictly match the data from the cell...
* Searching for "Lux" won't show "Luxembourg" event if it starts if the same letters!
*
* @default null
* @see http://www.dynatable.com/#querying
*
* @example
* $('#search-year')
*/
queries?: JQuery;
/**
* @todo Find out how this `inputs.sorts` setting is useful + show an example
* @default null
* @see http://www.dynatable.com/#sorting
*/
sorts?: any;
/**
* Allows you to define the accepted modifier keys to trigger a multisort action
*
* @default ['ctrlKey', 'shiftKey', 'metaKey']
* @see https://en.wikipedia.org/wiki/Modifier_key
*/
multisort?: Array<string>;
/**
* @todo Find out how this `inputs.page` setting is useful + show an example
* @default null
*/
page?: any;
/**
* The events attached to the search/filtering inputs elements
*
* @default 'blur change'
*/
queryEvent?: string;
/**
* The jQuery object pointing to a target where to insert the recordCount html
*
* @default null
*
* @example
* $('#chart-status-text')
*/
recordCountTarget?: JQuery;
/**
* Determines where the recordCount is inserted
*
* @enum('before', 'after')
* @default 'after'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
recordCountPlacement?: string;
/**
* The target inside next to which the pagination block will be inserted (before or after).
* You can use a selector string, an Element or a JQuery.
*
* @default null
*/
paginationLinkTarget?: string|Element|JQuery;
/**
* Determines where the pagination links are inserted
*
* @enum('before', 'after')
* @default 'after'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
paginationLinkPlacement?: string;
/**
* The classname to be injected on the `<ul>` containing the pagination
*
* @default 'dynatable-pagination-links'
*/
paginationClass?: string;
/**
* The classname to be injected on every pagination link
*
* @default 'dynatable-page-link'
*/
paginationLinkClass?: string;
/**
* The classname to be injected on the previous page link
*
* @default 'dynatable-page-prev'
*/
paginationPrevClass?: string;
/**
* The classname to be injected on the next page link
*
* @default 'dynatable-page-next'
*/
paginationNextClass?: string;
/**
* The classname to be injected on the current page link
*
* @default 'dynatable-active-page'
*/
paginationActiveClass?: string;
/**
* The classname to be injected on the disabled page links
*
* @default 'dynatable-disabled-page'
*/
paginationDisabledClass?: string;
/**
* Text content for the previous page link
*
* @default 'Previous'
*/
paginationPrev?: string;
/**
* Text content for the next page link
*
* @default 'Next'
*/
paginationNext?: string;
/**
* Define the number of page number links shown inside the pagination
*
* @default [1,2,2,1]
*/
paginationGap?: Array<number>;
/**
* The target next to which the search block will be inserted (before or after).
* You can use a selector string, an Element or a JQuery.
*
* @default null
*/
searchTarget?: string|Element|JQuery;
/**
* Determines where the search field is inserted
*
* @enum('before', 'after')
* @default 'before'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
searchPlacement?: string;
/**
* Text preceding the search field
*
* @default 'Search: '
*/
searchText?: string;
/**
* The target next to which the per page pagination block will be inserted (before or after).
* You can use a selector string, an Element or a jQuery object.
*
* @default null
*/
perPageTarget?: string|Element|JQuery;
/**
* Determines where the perPage menu is inserted
*
* @enum('before', 'after')
* @default 'before'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
perPagePlacement?: string;
/**
* Text content preceding the items per page <select>
*
* @default 'Show: '
*/
perPageText?: string;
/**
* Text content introducing the pagination
*
* @default 'Pages: '
*/
pageText?: string;
/**
* Text content used inside the recordsCount
*
* @default '{pageLowerBound} to {pageUpperBound} of'
*/
recordCountPageBoundTemplate?: string;
/**
* Text content used inside the recordsCount
*
* @default '{recordsShown} of'
*/
recordCountPageUnboundedTemplate?: string;
/**
* Text content used inside the recordsCount
*
* @default '{recordsQueryCount} {collectionName}'
*/
recordCountTotalTemplate?: string;
/**
* Text content used inside the recordsCount
*
* @default ' (filtered from {recordsTotal} total records)'
*/
recordCountFilteredTemplate?: string;
/**
* Text content used inside the recordsCount
*
* @default 'Showing '
*/
recordCountText?: string;
/**
* Text content used inside the recordsCount
*
* @default '{text} {pageTemplate} {totalTemplate} {filteredTemplate}'
*/
recordCountTextTemplate?: string;
/**
* Text content used inside the recordsCount
*
* @default '<span id="dynatable-record-count-{elementId}" class="dynatable-record-count">{textTemplate}</span>'
*/
recordCountTemplate?: string;
/**
* Text content injected inside the processingIndicator
*
* @default 'Processing...'
*/
processingText?: string;
}
interface Dataset {
/**
* Enable the `ajax` mode
*
* @default false
*/
ajax?: boolean;
/**
* A string containing the URL to which the request is sent.
*
* @default null
*/
ajaxUrl?: string;
/**
* Defining the `cache` setting for the jQuery's ajax call...
* true or false for dataType 'script' and 'jsonp'
*
* @default null
* @see http://api.jquery.com/jQuery.ajax
*/
ajaxCache?: boolean;
/**
* Send the ajax request automatically
*
* @default false
*/
ajaxOnLoad?: boolean;
/**
* Defining the `method` setting for the jQuery's ajax call...
* The HTTP method to use for the request (e.g. "POST", "GET", "PUT").
*
* @enum('GET', 'POST')
* @default 'GET'
* @todo Check if other methods could be used... ('GET', 'PUT', 'HEAD', 'POST', 'PATCH', 'TRACE', 'DELETE', 'CONNECT', 'OPTIONS', 'IS_AWARE', 'IS_EAGER', 'PROPFIND', 'IS_OPTIONAL', 'IS_REQUIRED', 'IS_CONSTRUCTOR', 'IS_INSTANTIATOR')
*/
ajaxMethod?: string;
/**
* The type of data that you're expecting back from the server.
* If none is specified, jQuery will try to infer it based on the MIME type of the response...
*
* @enum('xml', 'html', 'script', 'json', 'jsonp', 'text')
* @default 'json'
* @see http://api.jquery.com/jQuery.ajax
*/
ajaxDataType?: string;
/**
* Name of the property in the dataset that contains the total number of records
*
* @default null
*/
totalRecordCount?: string;
/**
* Object describing the current request's filtering
*
* @default {}
*/
queries?: Object;
/**
* Name of the property in the dataset that contains the total number of records for the current query
*
* @default null
*/
queryRecordCount?: string;
/**
* The page represented in the for the current dataset
*
* @default null
*/
page?: number;
/**
* The default number of items loaded per page
*
* @default 10
*/
perPageDefault?: number;
/**
* The default options available in the perPage menu built by dynatable
*
* @default [10,20,50,100]
*/
perPageOptions?: Array<number>;
/**
* Object describing the current request's sorting
*
* @default {}
*/
sorts?: Object;
/**
* The sorting keys (generated by dynatable)
*
* @default null
*/
sortsKeys?: Array<string>;
/**
* The sorting types (generated by dynatable)
* It will hosts the type of object to sort (string, number, etc.)
*
* @default {}
*/
sortTypes?: Object;
/**
* The core data (generated or loaded by dynatable)
*
* @default null
*/
records?: any;
}
interface Writers {
/**
* Function that write the data inside each row
*
* @param rowIndex The index of the current row (from 0 to the perPage value)
* @param record A data object containing all the data for the current record (current line)
* @param columns An array of columns
* @param cellWriter A reference to the function responsible for writing inside the cell
* @return the data for the current cell
*
* @default defaultRowWriter
*
* @example
* function exampleRowWriter(rowIndex, record, columns, cellWriter) {
* var tr = '';
* // grab the record's attribute for each column
* for (var i = 0, len = columns.length; i < len; i++) {
* tr += cellWriter(columns[i], record);
* }
* return '<tr>' + tr + '</tr>';
* };
*/
_rowWriter?: (rowIndex: number, record: any, columns: Array<Column>, cellWriter: Function) => string;
/**
* Function that returns the HTML code that will be injected for the cell
*
* @param column The column object describing the config for the current column
* @param record A data object representing the current line of data
* @return the data for the current cell
*
* @default defaultCellWriter
*
* @example
* function exampleCellWriter(column, record) {
* var html = column.attributeWriter(record),
* td = '<td';
*
* if (column.hidden || column.textAlign) {
* td += ' style="';
*
* // keep cells for hidden column headers hidden
* if (column.hidden) {
* td += 'display: none;';
* }
*
* // keep cells aligned as their column headers are aligned
* if (column.textAlign) {
* td += 'text-align: ' + column.textAlign + ';';
* }
*
* td += '"';
* }
*
* return td + '>' + html + '</td>';
* };
*/
_cellWriter?: (column: Column, record: any) => string;
/**
* Function that returns the cell data to be written inside the cell
*
* @param record A data object representing the current line of data
* @return the data for the current cell
*
* @default defaultAttributeWriter
*
* @example
* function exampleAttributeWriter(record) {
* // `this` is the column object in settings.columns
* return record[this.id];
* };
*/
_attributeWriter?: (record: any) => any;
}
interface Readers {
/**
* Function that interprets the row into data
*
* @param index The index of the current row (from 0 to the perPage value)
* @param thisRef
* @param record
* @return the data for the current row
*
* @default null
*
* @example
* function exampleRowReader(index, this, record) {
* //...
* };
*/
_rowReader?: (index: number, thisRef: any, record: any) => any;
/**
* Function that interprets the cell into data
*
* @param cell A html node of the target cell
* @param record A data object representing the current line of data
* @return the data for the current cell
*
* @default defaultAttributeReader
*
* @example
* function exampleAttributeReader(cell, record) {
* return $(cell).html();
* };
*/
_attributeReader?: (cell: Element, record: any) => any;
}
interface Params {
/**
* @default 'dynatable'
*/
dynatable?: string;
/**
* @default 'queries'
*/
queries?: string;
/**
* @default 'sorts'
*/
sorts?: string;
/**
* @default 'page'
*/
page?: string;
/**
* @default 'perPage'
*/
perPage?: string;
/**
* @default 'offset'
*/
offset?: string;
/**
* @default 'records'
*/
records?: string;
/**
* @default null
*/
record?: Object;
/**
* @default 'queryRecordCount'
*/
queryRecordCount?: string;
/**
* @default 'totalRecordCount'
*/
totalRecordCount?: string;
}
interface Options {
features?: Features;
table?: Table;
inputs?: Inputs;
dataset?: Dataset;
writers?: Writers;
readers?: Readers;
params?: Params;
}
interface DOM {
/**
* Manually update the dom with the current record set...
* This can be useful after multiple calls to `domcolumns.add()` with `skipUpdate` set to true.
* This way we improve performance by generating the DOM only once.
*/
update(): void;
}
interface DOMColumns {
/**
* Add a new column at runtime
*
* @param $column A jQuery object containing the html markup for the `th`
* @param position The position index indicating where we want to insert the new column
* @param skipAppend A boolean allowing to skip the appending of the column header to table
* @param skipUpdate A boolean allowing to skip the call to `dom.update()`
*/
add($column: JQuery, position: number, skipAppend?: boolean, skipUpdate?: boolean): void;
/**
* Add several `data-` attributes on the provided `$cell`
*
* @param $cell A jQuery object pointing to the target cell
* @return the modified jQuery object `$cell`
*/
attachGeneratedAttributes($cell: JQuery): JQuery;
/**
* Generate a jQuery object if none is provided and decorate it by calling `attachGeneratedAttributes`
*
* @param $cell An optional jQuery object pointing to the target cell
*/
generate($cell?: JQuery): JQuery;
/**
* Parse the table header row, analyse its cells and save the columns.
*
* @return Could return an `$.error()` if nothing is found.
*/
getFromTable(): void|JQuery;
/** Initializes `settings.table.columns` array and calls `getFromTable()` */
init(): void;
/**
* Check if the `$element` is valid (if it is a `table`)
*
* @return A boolean
*/
initOnLoad(): boolean;
/**
* Generate a jQuery object if none is provided and decorate it by calling `attachGeneratedAttributes`
*
* @param columnIndexOrId A number (the column index) or a string (the column id)
*/
remove(columnIndexOrId: number|string): void;
/**
* Remove the column from `settings.table.columns`
*
* @param index A number (the column index)
*/
removeFromArray(index: number): void;
/**
* Remove the column from the DOM
*
* @param columnId A string matching the id used in `data-dynatable-column` attribute
*/
removeFromTable(columnId: string): void;
}
interface InputsSearch {
/** Inject the search form at the target location */
attach(): void;
/**
* Build the html markup for the search form
*
* @return The jQuery object for the search form
*/
create(): JQuery;
/** Call the `attach()` method */
init(): void;
/**
* Check if the search feature is enabled in `settings.features`
*
* @return A boolean
*/
initOnLoad(): boolean;
}
interface PaginationLinks {
/** Insert the pagination links inside the page */
attach(): void;
/**
* Generate a string containing the html of a pagination link
*
* @param page The page number
* @param label The text of the link (could be Previous, Next or a number)
* @param linkClass The classname for the `<a>`
* @param conditional Do we want to use the conditionalClass
* @param conditionalClass The classname for both the `<li>` and its `<a>`
* @return A string containing html markup
*/
buildLink(page: number, label: string|number, linkClass: string, conditional: boolean, conditionalClass: string): string;
/**
* Build the `<ul>` and creates the event listeners
*
* @return A string containing html markup
*/
create(): string;
/** Call the attach method */
init(): void;
/**
* Check if the paginate feature is enabled in `settings.features`
*
* @return A boolean
*/
initOnLoad(): boolean;
}
interface PaginationPage {
/** Parse the current window.location in order to determine the target page */
init(): void;
/**
* Check if the paginate feature is enabled in `settings.features`
*
* @return A boolean
*/
initOnLoad(): boolean;
/**
* Set the page in the dataset
*
* @param page The new page number
*/
set(page: number): void;
}
interface PaginationPerPage {
/** Insert the pagination per page inside the page */
attach(): void;
/**
* Generate the html markup for the pagination per page
*
* @return A jQuery object containing the `<label>` and the `<select>`
*/
create(): JQuery;
/** Set up the pagination per page */
init(): void;
/**
* Check if the paginate feature is enabled in `settings.features`
*
* @return A boolean
*/
initOnLoad(): boolean;
/**
* Set the new value for the pagination per page
*
* @param number The new number of items visible per page
* @param skipResetPage By default (false) it sends you to page 1
*/
set(number: number, skipResetPage?: boolean): void;
}
interface ProcessingIndicator {
/** Insert the processing indicator inside the page */
attach(): void;
/**
* Generate the html markup for the processing indicator
*
* @return A jQuery object containing the generated html
*/
create(): JQuery;
/** Hide the processing indicator */
hide(): void;
/** Set up the processing indicator */
init(): void;
/**
* Position the processing indicator at the center
*
* @return A jQuery object containing the processing indicator
*/
position(): JQuery;
/** Show the processing indicator */
show(): void;
}
interface Queries {
/**
* Add a new condition in the queries
*
* @param name The key for for the query
* @param value The value we wish to find
* @return A reference to the related Dynatable object
*/
add(name: string, value: any): Dynatable;
/** functions object for Queries */
functions: QueriesFunctions;
/** Set up the initial search parameters */
init(): void;
/**
* Check if search feature is enabled
*
* @return A boolean if search feature is enabled
*/
initOnLoad(): boolean;
/**
* Remove the query from the dataset
*
* @param name The key for for the query to be removed
* @return A reference to the related Dynatable object
*/
remove(name: string): Dynatable;
/** Run a search with all the saved queries */
run(): any;
/**
* Shortcut for performing simple query from built-in search
*
* @param q The value that will be searched for
*/
runSearch(q: any): void;
/** Set up the input fields for creating queries */
setupInputs(): void;
}
interface QueriesFunctions {
/**
* Search in all of the properties of the provided single record
*
* @param record A data object with all the properties of the current line
* @param queryValue The researched value
* @return A boolean indicating if a match was found
*/
search(record: any, queryValue: string): boolean;
}
interface Records {
/**
* Count records from table
*
* @return The length of the records Array
*/
count(): number;
/**
* Get initial recordset to populate table
* if ajax, call ajaxUrl
* otherwise, initialize from in-table records
*
* @return An Array with the records
*/
getFromTable(): Array<Object>;
/** Create and init the records */
init(): void;
/**
* Check if ajax feature is enabled
*
* @return A boolean if ajax feature is enabled
*/
initOnLoad(): boolean;
/**
* Get the first and the last indexes based on current page and number of items per page
*
* @return An Array with the first index ([0]) and the last index ([1])
*/
pageBounds(): Array<number>;
/** Update the records with the new page */
paginate(): void;
/** Reset the records */
resetOriginal(): void;
/**
* Call the appropriated sort function
*
* @return The number (-1, 0 or +1) representing the comparison
*/
sort(): number;
/**
* Merge ajax response json with cached data including (meta-data and records)
*
* @param data The new data
*/
updateFromJson(data: any): void;
}
interface RecordsCount {
/** Insert the record count inside the page */
attach(): void;
/**
* Generate the html markup for the record count
*
* @return A jQuery object containing the generated html
*/
create(): JQuery;
/** Create and init the records count */
init(): void;
/**
* Check if recordCount feature is enabled
*
* @return A boolean if recordCount feature is enabled
*/
initOnLoad(): boolean;
}
interface Settings {
dataset: Dataset;
features: Features;
inputs: Inputs;
params: Params;
readers: Readers;
table: Table;
writers: Writers;
}
interface Sorts {
/**
* Add a new sort in sortKeys
*
* @param attr The key for for the sorting
* @param direction The sorting direction (-1 or +1)
* @return A reference to the related Dynatable object
*/
add(attr: string, direction: number): Dynatable;
/** Remove all the sortKeys */
clear(): void;
/** functions object for Sorts */
functions: SortsFunctions;
/**
* Try to intelligently guess which sort function to use based on the type of attribute values.
*
* @param a The first record
* @param b The second record
* @param attr The key of the property
* @return A string containing one of the types ('string' or 'number')
*/
guessType(a: any, b: any, attr: string): string;
/** Create and init the sorts */
init(): void;
/**
* Check if sort feature is enabled
*
* @return A boolean if sort feature is enabled
*/
initOnLoad(): boolean;
/**
* Remove a sort attribute from the sortKeys
*
* @param attr The key to be removed from the sorting
* @return A reference to the related Dynatable object
*/
remove(attr: string): Dynatable;
}
interface SortsFunctions {
/**
* Sorting between 2 numbers
*
* @param a The first record
* @param b The second record
* @param attr The key of the property
* @param direction The number describingthe order: ASC (+1), DESC (-1) or none (0)
* @return The number (-1, 0 or +1) representing the comparison
*/
number(a: any, b: any, attr: string, direction: number): number;
/**
* Restores the original order we had...
*
* @param a The first record
* @param b The second record
* @return The number (-1, 0 or +1) representing the comparison
*/
originalPlacement(a: any, b: any): number;
/**
* Sorting between 2 strings
*
* @param a The first record
* @param b The second record
* @param attr The key of the property
* @param direction The number describingthe order: ASC (+1), DESC (-1) or none (0)
* @return The number (-1, 0 or +1) representing the comparison
*/
string(a: any, b: any, attr: string, direction: number): number;
}
interface SortsHeaders {
/**