forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery-handsontable.d.ts
950 lines (768 loc) · 36.9 KB
/
jquery-handsontable.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
// Type definitions for jquery-handsontable
// Project: http://handsontable.com
// Definitions by: Ted John <https://github.com/intelorca>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts"/>
declare module Handsontable {
interface CellPosition {
row: number;
col: number;
}
interface Options {
/**
* Initial data source that will be bound to the data grid by reference (editing data grid alters the data source. See Understanding binding as reference.
*/
data?: any;
/**
* Width of the grid. Can be a number or a function that returns a number.
*/
width?: any;
/**
* Height of the grid. Can be a number or a function that returns a number.
*/
height?: any;
/**
* Minimum number of rows. At least that many of rows will be created during initialization.
*/
minRows?: number;
/**
* Minimum number of columns. At least that many of columns will be created during initialization.
*/
minCols?: number;
/**
* Maximum number of rows.
*/
maxRows?: number;
/**
* Maximum number of columns.
*/
maxCols?: number;
/**
* Initial number of rows. Notice: This option only has effect in Handsontable constructor and only if data option is not provided.
*/
startRows?: number;
/**
* Initial number of rows. Notice: This option only has effect in Handsontable constructor and only if data option is not provided.
*/
startCols?: number;
/**
* Setting true or false will enable or disable the default row headers (1, 2, 3). You can also define an array ['One', 'Two', 'Three', ...] or a function to define the headers. If a function is set the index of the rowis passed as a parameter.
*/
rowHeaders?: any;
/**
* Setting true or false will enable or disable the default column headers (A, B, C). You can also define an array ['One', 'Two', 'Three', ...] or a function to define the headers. If a function is set the index of the column is passed as a parameter.
*/
colHeaders?: any;
/**
* Defines column widths in pixels. Accepts number, string (that will be converted to number), array of numbers (if you want to define column width separately for each column) or a function (if you want to set column width dynamically on each render).
*/
colWidths?: any;
/**
* Defines the cell properties and data binding for certain columns. Notice: Using this option sets a fixed number of columns (options startCols, minCols, maxCols will be ignored).
* @see https://github.com/handsontable/jquery-handsontable/wiki/Options below for more detailed explanation.
* @see http://handsontable.com/demo/datasources.html for examples
*/
columns?: any[];
/**
* Defines the cell properties for given row, col, prop coordinates.
* See Cells section below for more detailed explanation.
*/
cells?: (row: number, col: number, prop: string) => void;
/**
* Defines the structure of a new row when data source is an object.
* @see http://handsontable.com/demo/datasources.html for examples.
*/
dataSchema?: any;
/**
* When set to 1 (or more), Handsontable will add a new row at the end of grid if there are no more empty rows.
*/
minSpareRows?: number;
/**
* When set to 1 (or more), Handsontable will add a new column at the end of grid if there are no more empty columns.
*/
minSpareCols?: number;
/**
* If true, selection of multiple cells using keyboard or mouse is allowed.
*/
multiSelect?: boolean;
/**
* Enables the fill handle (drag-down and copy-down) functionality, which shows the small rectangle in bottom right corner of the selected area, that let's you expand values to the adjacent cells.
* Possible values: true (to enable in all directions), "vertical" or "horizontal" (to enable in one direction), false (to disable completely). Setting to true enables the fillHandle plugin, which,
*/
fillHandle?: any;
/**
* Defines if the right-click context menu should be enabled. Context menu allows to create new row or column at any place in the grid.
* Possible values: true (to enable basic options), false (to disable completely) or array of any available strings: ["row_above", "row_below", "col_left", "col_right", "remove_row", "remove_col", "undo", "redo", "sep1", "sep2", "sep3"].
* @see http://handsontable.com/demo/contextmenu.html for examples.
*/
contextMenu?: any;
/**
* If true, undo/redo functionality is enabled.
*/
undo?: boolean;
/**
* If true, mouse click outside the grid will deselect the current selection.
*/
outsideClickDeselects?: boolean;
/**
* If true, ENTER begins editing mode (like Google Docs). If false, ENTER moves to next row (like Excel) and adds new row if necessary. TAB adds new column if necessary.
*/
enterBeginsEditing?: boolean;
/**
* Defines cursor move after ENTER is pressed (SHIFT+ENTER uses negative vector). Can be an object or a function that returns an object. The event argument passed to the function is a jQuery.Event object received after a ENTER key has been pressed. This event object can be used to check whether user pressed ENTER or SHIFT + ENTER.
*/
enterMoves?: any;
/**
* Defines cursor move after TAB is pressed (SHIFT+TAB uses negative vector). Can be an object or a function that returns an object. The event argument passed to the function is a jQuery.Event object received after a TAB key has been pressed. This event object can be used to check whether user pressed TAB or SHIFT + TAB.
*/
tabMoves?: any;
/**
* If true, pressing TAB or right arrow in the last column will move to first column in next row.
*/
autoWrapRow?: boolean;
/**
* If true, pressing ENTER or down arrow in the last row will move to first row in next column.
*/
autoWrapCol?: boolean;
/**
* Autocomplete definitions.
* @see demo/autocomplete.html for examples and definitions.
*/
autoComplete?: any[];
/**
* Maximum number of rows than can be copied to clipboard using CTRL+C.
*/
copyRowsLimit?: number;
/**
* Maximum number of columns than can be copied to clipboard using CTRL+C.
*/
copyColsLimit?: number;
/**
* Defines paste (CTRL+V) behavior. Default value "overwrite" will paste clipboard value over current selection.
* When set to "shift_down", clipboard data will be pasted in place of current selection, while all selected cells are moved down.
* When set to "shift_right", clipboard data will be pasted in place of current selection, while all selected cells are moved right.
*/
pasteMode?: string;
/**
* Column stretching mode. Possible values: "none", "last", "all".
*/
stretchH?: string;
/**
* Lets you overwrite the default isEmptyRow method.
*/
isEmptyRow?: (row: number) => boolean;
/**
* Lets you overwrite the default isEmptyCol method.
*/
isEmptyCol?: (col: number) => boolean;
/**
* Turn on Manual column resize, if set to a boolean or define initial column resized widths, if set to an array of numbers.
*/
manualColumnResize?: any;
/**
* Turn on Manual column move, if set to a boolean or define initial column order, if set to an array of column indexes.
*/
manualColumnMove?: any;
/**
* Turn on Column sorting.
*/
columnSorting?: boolean;
/**
* Turn on saving the state of column sorting, columns positions and columns sizes in local storage. For more information see How to save data localy.
*/
persistentState?: boolean;
/**
* Class name for all visible rows in current selection.
*/
currentRowClassName?: string;
/**
* Class name for all visible columns in current selection.
*/
currentColClassName?: string;
/**
* Allows to specify the number of rows fixed (aka freezed) on the top of the table.
*/
fixedRowsTop?: number;
/**
* Allows to specify the number of columns fixed (aka freezed) on the left side of the table.
*/
fixedColumnsLeft?: number;
/**
* Setting to true enables selecting just a fragment of the text within a single cell or between adjacent cells.
*/
fragmentSelection?: boolean;
/**
* Setting to true word wrapping of the cell text content that does not fit in the fixed column width.
*/
wordWrap?: boolean;
/**
* CSS class name cells configured with wordWrap: false.
*/
noWordWrapClassName?: string;
/**
* When set to an non-empty string, displayed as the cell content for empty cells.
*/
placeholder?: any;
/**
* CSS class name for cells that have a placeholder in use.
*/
placeholderCellClassName?: string;
/**
* CSS class name for cells that did not pass validation.
*/
invalidCellClassName?: string;
/**
* CSS class name for read-only cells.
*/
readOnlyCellClassName?: string;
/**
* Setting to true enables the debug mode, currently used to test the correctness of the row and column header fixed positioning on a layer above the master table.
*/
debug?: boolean;
/**
* When set to true, the table is rerendered when it is detected that it was made visible in DOM.
*/
observeDOMVisibility?: boolean;
/**
* Setting to true enables the autoColumnSize plugin, which makes sure each column gets enough space to show its content.
*/
autoColumnSize?: boolean;
/**
* Setting to true enables the observeChanges plugin, which automatically renders the table when a change in the data source is observed.
*/
observeChanges?: boolean;
/**
* Setting to true enables the manualRowResize plugin, which allows to resize the row height with your mouse.
*/
manualRowResize?: boolean;
/**
* Setting to true enables the copyPaste plugin, which enables the copying and pasting to the clipboard.
*/
copyPaste?: boolean;
/**
* Setting to true enables the search plugin (see demo).
*/
search?: boolean;
/**
* Setting to true or array enables the mergeCells plugin, which enables the merging of the cells. (see demo). You can provide the merged cells on the pageload if you feed the mergeCells option with an array.
*/
mergeCells?: any;
/**
* Callback fired before Walkontable instance is initiated.
*/
beforeInitWalkontable?: Function;
/**
* Callback fired before Handsontable instance is initiated.
* Note: this can be set only by global PluginHooks instance.
*/
beforeInit?: Function;
/**
* Callback fired before Handsontable table is rendered. Parameters:
* - isForced is true if rendering was triggered by a change of settings or data; or false if rendering was triggered by scrolling or moving selection.
*/
beforeRender?: (isForced: boolean) => void;
/**
* Callback fired before one or more cells is changed. Its main purpose is to alter changes silently before input. Parameters:
* - changes is a 2D array containing information about each of the edited cells [ [row, prop, oldVal, newVal], ... ].
* - To disregard a single change, set changes[i] to null or remove it from array using changes.splice(i, 1).
* - To alter a single change, overwrite the desired value to changes[i][3].
* - To cancel all edit, return false from the callback or set array length to 0 (changes.length = 0).
* - source is the name of a source of changes.
*/
beforeChange?: (changes: any[][], source: string) => void;
beforeChangeRender?: Function;
/**
* Callback fired before sorting the table. The column argument is a relative (displayed) index of a column that is about to be sorted. To get the absolute column index, just add the current column offset. You can get the offset by using colOffset() method.
*/
beforeColumnSort?: (column: number, order: boolean) => void;
/**
* Callback fired before setting single value from the data source array.
*/
beforeSet?: (v: Object) => void;
/**
* Callback fired before getting cell settings.
*/
beforeGetCellMeta?: (row: number, col: number, cellProperties: Object) => void;
/**
* Parameters:
* - start is an object containing information about first filled cell: { row : 2, col : 0 }.
* - end is an object containing information about last filled cell: { row : 4, col : 1 }.
* - data is an 2D array containing information about fill pattern: [ ["1", "Ted"], ["1", "John"] ].
*/
beforeAutofill?: (start: CellPosition, end: CellPosition, data: string[][]) => void;
/**
* Callback fired before keydown event is handled. It can be used to overwrite default key bindings. Caution - in your beforeKeyDown handler you need to call event.stopImmediatePropagation() to prevent default key behavior.
*/
beforeKeyDown?: (event: KeyboardEvent) => void;
/**
* A plugin hook executed before validator function, only if validator function is defined. This can be used to manipulate value of changed cell before it is applied to the validator function. NOTICE: this will not affect values of changes. This will change value ONLY for validation!
*/
beforeValidate?: (value: any, row: number, prop: string, source: string) => void;
/**
* Callback fired after Handsontable instance is initiated.
*/
afterInit?: Function;
/**
* Callback fired after new data is loaded (by loadData method) into the data source array.
*/
afterLoadData?: Function;
/**
* Callback fired after Handsontable table is rendered. Parameters:
* - isForced is true if rendering was triggered by a change of settings or data; or false if rendering was triggered by scrolling or moving selection.
*/
afterRender?: (isForced: boolean) => void;
/**
* Callback fired after one or more cells is changed. Its main use case is to save the input. Parameters:
* - changes is a 2D array containing information about each of the edited cells [ [row, prop, oldVal, newVal], ... ].
* - source is one of the strings: "alter", "empty", "edit", "populateFromArray", "loadData", "autofill", "paste".
* Note: for performance reasons, the changes array is null for "loadData" source.
*/
afterChange?: (changes: any[], source: string) => void;
/**
* Callback fired after sorting the table. The column argument is a relative (displayed) index of a column that is about to be sorted. To get the absolute column index, just add the current column offset. You can get the offset by using colOffset() method.
*/
afterColumnSort?: (column: number, order: boolean) => void;
/**
* Callback fired while one or more cells are being selected (on mouse move). Parameters:
* - r selection start row
* - c selection start column
* - r2 selection end row
* - c2 selection end column
*/
afterSelection?: (r: number, c: number, r2: number, c2: number) => void;
/**
* The same as above, but data source object property name is used instead of the column number.
*/
afterSelectionByProp?: (r: number, p: string, r2: number, p2: string) => void;
/**
* Callback fired while one or more cells are being selected (on mouse up). Parameters:
* - r selection start row
* - c selection start column
* - r2 selection end row
* - c2 selection end column
*/
afterSelectionEnd?: (r: number, c: number, r2: number, c2: number) => void;
/**
* The same as above, but data source object property name is used instead of the column number.
*/
afterSelectionEndByProp?: (r: number, p: string, r2: number, p2: string) => void;
/**
* Event called when current cell is deselected.
*/
afterDeselect?: Function;
/**
* Callback fired after getting cell settings.
*/
afterGetCellMeta?: (row: number, col: number, cellProperties: Object) => void;
/**
* Callback fired after getting info about column header.
*/
afterGetColHeader?: (col: number, TH: HTMLTableHeaderCellElement) => void;
/**
* Callback fired after calculating column width.
*/
afterGetColWidth?: (col: number, response: Object) => void;
/**
* Callback fired after destroing Handsontable instance.
*/
afterDestroy?: Function;
/**
* Callback is fired when a new row is created. Parameters:
* - index represents the index of first newly created row in the data source array.
* - amount number of newly created rows in the data source array.
*/
afterCreateRow?: (index: number, amount: number) => void;
/**
* Callback is fired when a new column is created. Parameters:
* - index represents the index of first newly created column in the data source array.
* - amount number of newly created columns in the data source array.
*/
afterCreateCol?: (index: number, amount: number) => void;
/**
* Callback is fired when one or more rows are about to be removed. Parameters:
* - index is an index of starter row.
* - amount is an anount of rows to be removed.
*/
beforeRemoveRow?: (index: number, amount: number) => void;
/**
* Callback is fired when one or more rows are removed. Parameters:
* - index is an index of starter row.
* - amount is an anount of removed rows.
*/
afterRemoveRow?: (index: number, amount: number) => void;
/**
* Callback is fired when one or more columns are about to be removed. Parameters:
* - index is an index of starter column.
* - amount is an anount of columns to be removed.
*/
beforeRemoveCol?: (index: number, amount: number) => void;
/**
* Callback is fired when one or more columns are removed. Parameters:
* - index is an index of starter column.
* - amount is an anount of removed columns.
*/
afterRemoveCol?: (index: number, amount: number) => void;
/**
* Callback is fired after changing column size.
*/
afterColumnResize?: (col: number, size: number) => void;
/**
* Callback is fired after changing column placement.
*/
afterColumnMove?: (oldIndex: number, newIndex: number) => void;
/**
* Callback fired if copyRowsLimit or copyColumnsLimit was reached.
*/
afterCopyLimit?: (selectedRowsCount: number, selectedColsCount: number, copyRowsLimit: number, copyColsLimit: number) => void;
/**
* A plugin hook executed after validator function, only if validator function is defined. Validation result is the first parameter. This can be used to determinate if validation passed successfully or not. You can cancel current change by returning false.
*/
afterValidate?: (isValid: boolean, value: any, row: number, prop: string, source: string) => boolean;
/**
* Callback fired before setting range is ended. Parameters:
* - coords is WalkontableCellCoords array
*/
beforeSetRangeEnd?: (coords: any[]) => void;
afterUpdateSettings?: Function;
afterRenderer?: (TD: HTMLTableDataCellElement, row: number, col: number, prop: string, value: string, cellProperties: Object) => void;
/**
* Callback fired after clicking on a cell or row/column header.
* In case the row/column header was clicked, the index is negative. For example clicking on the row header of cell (0, 0) results with afterOnCellMouseDown called with coords {row: 0, col: -1}.
*/
afterOnCellMouseDown?: (event: MouseEvent, coords: CellPosition, TD: HTMLTableDataCellElement) => void;
/**
* Callback fired after hovering a cell or row/column header with the mouse cursor.
* In case the row/column header was hovered, the index is negative. For example clicking on the row header of cell (0, 0) results with afterOnCellMouseOver called with coords {row: 0, col: -1}.
*/
afterOnCellMouseOver?: (event: MouseEvent, coords: CellPosition, TD: HTMLTableDataCellElement) => void;
/**
* Callback fired after.
*/
afterOnCellCornerMouseDown?: (event: MouseEvent) => void;
afterScrollVertically?: Function;
afterScrollHorizontally?: Function;
/**
* Callback fired after reset cell's meta.
*/
afterCellMetaReset?: Function;
/**
* Callback fired after modify column's width.
*/
modifyColWidth?: (width: number, col: number) => void;
/**
* Callback fired after modify hight of row.
*/
modifyRowHeight?: (height: number, row: number) => void;
/**
* Callback fired after row modify.
*/
modifyRow?: (row: number) => void;
/**
* Callback fired after column modify.
*/
modifyCol?: (col: number) => void;
afterSetCellMeta?: Function;
/**
* Deprecated! Now event is called afterSelection.
*/
onSelection?: (r: number, p: number, r2: number, p2: number) => void;
/**
* Deprecated! Now event is called afterSelectionByProp.
*/
onSelectionByProp?: (r: number, p: number, r2: number, p2: number) => void;
/**
* Deprecated! Now event is called afterSelectionEnd.
*/
onSelectionEnd?: (r: number, p: number, r2: number, p2: number) => void;
/**
* Deprecated! Now event is called afterSelectionEndByProp.
*/
onSelectionEndByProp?: (r: number, p: number, r2: number, p2: number) => void;
/**
* Deprecated! Now event is called beforeChange.
*/
onBeforeChange?: (changes: any[], source: string) => void;
/**
* Deprecated! Now event is called afterChange.
*/
onChange?: (changes: any[], source: string) => void;
/**
* Deprecated! Now event is called afterCopyLimit.
*/
onCopyLimit?: (selectedRowsCount: number, selectedColsCount: number, copyRowsLimit: number, copyColsLimit: number) => void;
}
interface Context {
/**
* Use it if you need to change configuration after initialization.
*/
updateSettings(options: Options): void;
/**
* Returns an object containing the current grid settings.
*/
getSettings(): Options;
/**
* Reset all cells in the grid to contain data from the data array.
*/
loadData(data: any[]): void;
/**
* Listen to keyboard input on document body.
*/
listen(): void;
/**
* Returns rederer type/
*/
getCellRenderer(row: number, col: number): string;
/**
* Stop listening to keyboard input on document body.
*/
unlisten(): void;
/**
* Returns true if current Handsontable instance is listening to keyboard input on document body.
*/
isListening(): boolean;
/**
* Rerender the table.
*/
render(): void;
/**
* Remove grid from DOM.
*/
destroy(): void;
/**
* Validates all cells using their validator functions and calls callback when finished. Does not render the view.
*/
validateCells(callback: Function): void;
/**
* Return the current data object (the same that was passed by data configuration option or loadData method). Optionally you can provide cell range row, col, row2, col2 to get only a fragment of grid data
*/
getData(): any;
/**
* Return the current data object (the same that was passed by data configuration option or loadData method). Optionally you can provide cell range row, col, row2, col2 to get only a fragment of grid data
*/
getData(row: number, col: number, row2: number, col2: number): any;
/**
* Return cell value at row, col. row and col are the visible indexes (note that if columns were reordered or sorted, the current order will be used).
*/
getDataAtCell(row: number, col: number): any;
/**
* Same as getDataAtCell, except instead of col, you provide name of the object property (e.g. 'first.name').
*/
getDataAtRowProp(row: number, prop: string): any;
/**
* Returns a single row of the data (array or object, depending on what you have). row is the visible index of the row
*/
getDataAtRow(row: number): any;
/**
* Returns a single row of the data (array or object, depending on what you have). row is the index of the row in the data source.
*/
getSourceDataAtRow(row: number): any;
/**
* Returns array of column values from the data source. col is the visible index of the column.
*/
getDataAtCol(col: number): any[];
/**
* Returns array of column values from the data source. col is the index of the row in the data source.
*/
getSourceDataAtCol(col: number): any[];
/**
* Given the object property name (e.g. 'first.name'), returns array of column values from the data source.
*/
getDataAtProp(prop: string): any[];
/**
* Get value of selected range. Each column is separated by tab, each row is separated by new line character.
*/
getCopyableData(startRow: number, startCol: number, endRow: number, endCol: number): any;
/**
* Returns value of selected cell.
*/
getValue(): any;
/**
* Set new value to a cell. To change many cells at once, pass an array of changes in format [ [row, col, value], ... ] as the only parameter. col is the index of visible column (note that if columns were reordered, the current order will be used). source is a flag for before/afterChange events. If you pass only array of changes then source could be set as second parameter.
*/
setDataAtCell(row: number, col: number, value: any, source?: string): void;
/**
* Set new value to a cell. To change many cells at once, pass an array of changes in format [ [row, col, value], ... ] as the only parameter. col is the index of visible column (note that if columns were reordered, the current order will be used). source is a flag for before/afterChange events. If you pass only array of changes then source could be set as second parameter.
*/
setDataAtCell(changes: any[], source?: string): void;
/**
* Same as above, except instead of col, you provide name of the object property (e.g. [0, 'first.name', 'Jennifer']).
*/
setDataAtRowProp(row: number, prop: string, value: any, source?: string): void;
/**
* Same as above, except instead of col, you provide name of the object property (e.g. [0, 'first.name', 'Jennifer']).
*/
setDataAtRowProp(changes: any[], source?: string): void;
/**
* Populate cells at position with 2D input array (e.g. [ [1, 2], [3, 4] ]).
* Use endRow, endCol when you want to cut input when certain row is reached.
* @param source (default value "populateFromArray") is used to identify this call in the resulting events (beforeChange, afterChange).
* @param populateMethod (default value "overwrite", possible values "shift_down" and "shift_right") has the same effect as pasteMethod option (see Options page).
*/
populateFromArray(row: number, col: number, input: any[], endRow: number, endCol: number, source?: string, populateMethod?: string): void;
/**
* Adds/removes data from the column. This function works is modelled after Array.splice. Parameter col is the index of column in which do you want to do splice. Parameter index is the row index at which to start changing the array. If negative, will begin that many elements from the end. Parameter amount, is the number of old array elements to remove. If the amount is 0, no elements are removed. Fourth and further parameters are the elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
*/
spliceCol(col: number, index: number, amount: number, ...elements: any[]): void;
/**
* Adds/removes data from the row. This function works is modelled after Array.splice. Parameter row is the index of row in which do you want to do splice. Parameter index is the column index at which to start changing the array. If negative, will begin that many elements from the end. Parameter amount, is the number of old array elements to remove. If the amount is 0, no elements are removed. Fourth and further parameters are the elements to add to the array. If you don't specify any elements, spliceCol simply removes elements from the array.
*/
spliceRow(row: number, index: number, amount: number, ...elements: any[]): void;
/**
* Insert new row(s) above the row at given index. If index is null or undefined, the new row will be added after the current last row. Default amount equals 1.
*/
alter(type: 'insert_row', index: number, amount?: number, source?: string): void;
/**
* Insert new column(s) before the column at given index. If index is null or undefined, the new column will be added after the current last column. Default amount equals 1.
*/
alter(type: 'insert_col', index: number, amount?: number, source?: string): void;
/**
* Remove the row(s) at given index. Default amount equals 1.
*/
alter(type: 'remove_row', index: number, amount?: number, source?: string): void;
/**
* Remove the column(s) at given index. Default amount equals 1.
*/
alter(type: 'remove_col', index: number, amount?: number, source?: string): void;
alter(type: string, index: number, amount?: number, source?: string): void;
/**
* Returns TD element for given row, col if it is rendered on screen.
* Returns null if the TD is not rendered on screen (probably because that part of table is not visible).
*/
getCell(row: number, col: number): any;
/**
* Return cell properties for given row, col coordinates.
*/
getCellMeta(row: number, col: number): any;
/**
* Sets cell meta data object key corresponding to params row, col.
*/
setCellMeta(row: number, col: number, key: string, val: string): void;
/**
* Destroys current editor, renders and selects current cell. If revertOriginal == false, edited data is saved. Otherwise previous value is restored.
*/
destroyEditor(revertOriginal?: boolean): void;
/**
* Select cell row, col or range finishing at row2, col2. By default, viewport will be scrolled to selection.
*/
selectCell(row: number, col: number, row2: number, col2: number, scrollToSelection?: boolean): void;
/**
* Deselect current selection.
*/
deselectCell(): void;
/**
* Return index of the currently selected cells as an array [startRow, startCol, endRow, endCol]. Start row and start col are the coordinates of the active cell (where the selection was started).
*/
getSelected(): void;
/**
* Returns current selection as a WalkontableCellRange object. Returns undefined if there is no selection.
*/
getSelectedRange(): void;
/**
* Clears grid.
*/
clear(): void;
/**
* Returns total number of rows in the grid.
*/
countRows(): number;
/**
* Returns total number of columns in the grid.
*/
countCols(): number;
/**
* Returns property name that corresponds with the given column index.
*/
colToProp(column: number): string;
/**
* Returns index of first visible row.
*/
rowOffset(): number;
/**
* Returns index of first visible column.
*/
colOffset(): number;
/**
* Returns number of visible rows.
*/
countVisibleRows(): number;
/**
* Returns number of visible columns.
*/
countVisibleCols(): number;
/**
* Returns number of empty rows. If the optional ending parameter is true, returns number of empty rows at the bottom of the table.
*/
countEmptyRows(ending?: boolean): number;
/**
* Returns number of empty columns.If the optional ending parameter is true, returns number of empty columns at right hand edge of the table.
*/
countEmptyCols(ending?: boolean): number;
/**
* Returns true if the row at the given index is empty, false otherwise.
*/
isEmptyRow(row: number): boolean;
/**
* Returns true if the column at the given index is empty, false otherwise.
*/
isEmptyCol(col: number): boolean;
/**
* Returns array of row headers (if they are enabled). If param row given, return header at given row as string.
*/
getRowHeader(row: number): any;
/**
* Returns array of col headers (if they are enabled). If param col given, return header at given col as string.
*/
getColHeader(col: number): any;
/**
* Returns information of this table is configured to display row headers.
*/
hasRowHeaders(): boolean;
/**
* Returns information of this table is configured to display column headers.
*/
hasColHeaders(): boolean;
/**
* Return column width.
*/
getColWidth(col: number): number;
/**
* Return row height.
*/
getRowHeight(row: number): number;
/**
* Returns column index that corresponds with the given property.
*/
propToCol(property: string): number;
/**
* Clear undo history.
*/
clearUndo(): void;
/**
* Return true if undo can be performed, false otherwise.
*/
isUndoAvailable(): boolean;
/**
* Return true if redo can be performed, false otherwise.
*/
isRedoAvailable(): boolean;
/**
* Undo last edit.
*/
undo(): void;
/**
* Redo edit (used to reverse an undo).
*/
redo(): void;
/**
* Sorts table content by cell values in given column, using order. column is a zero-based column index. Order of sorting can be either ascending (order = true) or descending (order = false).
* Note I: This method is only available when coulmnSorting plugin is enabled. See column sorting demo for details.
* Note II: Running this method will not alter the table data. Sorting takes place only in view layer.
*/
sort(column: number, order: boolean): void;
}
}
interface JQuery {
handsontable(): JQuery;
handsontable(methodName: string, ...arguments: any[]): any;
handsontable(options: Handsontable.Options): JQuery;
}