|
| 1 | +// Type definitions for DataTables RowGroup |
| 2 | +// |
| 3 | +// Project: https://datatables.net/extensions/rowgroup/, https://datatables.net |
| 4 | +// Definitions by: |
| 5 | +// SpryMedia |
| 6 | +// Matthieu Tabuteau <https://github.com/maixiu> |
1 | 7 |
|
2 | | -// Dist-DataTables-RowGroup-jQueryUI integration with jQueryUI exports the DataTables API having |
3 | | -// set default values to complete the ingeration. |
4 | | -import Api from "datatables.net"; |
| 8 | +/// <reference types="jquery" /> |
5 | 9 |
|
6 | | -export default Api; |
| 10 | +import DataTables, {Api} from 'datatables.net'; |
7 | 11 |
|
| 12 | +export default DataTables; |
| 13 | + |
| 14 | + |
| 15 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 16 | + * DataTables' types integration |
| 17 | + */ |
| 18 | +declare module 'datatables.net' { |
| 19 | + interface Config { |
| 20 | + /** |
| 21 | + * RowGroup extension options |
| 22 | + */ |
| 23 | + rowGroup?: boolean | ConfigRowGroup; |
| 24 | + } |
| 25 | + |
| 26 | + interface Api<T> { |
| 27 | + /** |
| 28 | + * RowGroup methods container |
| 29 | + * |
| 30 | + * @returns Api for chaining with the additional RowGroup methods |
| 31 | + */ |
| 32 | + rowGroup(): ApiRowGroup<T>; |
| 33 | + } |
| 34 | + |
| 35 | + interface ApiStatic { |
| 36 | + /** |
| 37 | + * RowGroup class |
| 38 | + */ |
| 39 | + RowGroup: { |
| 40 | + /** |
| 41 | + * Create a new RowGroup instance for the target DataTable |
| 42 | + */ |
| 43 | + new (dt: Api<any>, settings: boolean | ConfigRowGroup); |
| 44 | + |
| 45 | + /** |
| 46 | + * Default configuration values |
| 47 | + */ |
| 48 | + defaults: ConfigRowGroup; |
| 49 | + |
| 50 | + /** |
| 51 | + * RowGroup version |
| 52 | + */ |
| 53 | + version: string; |
| 54 | + } |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | + |
| 59 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 60 | + * Options |
| 61 | + */ |
| 62 | + |
| 63 | +interface ConfigRowGroup { |
| 64 | + /** |
| 65 | + * Set the class name to be used for the grouping rows |
| 66 | + */ |
| 67 | + className?: string; |
| 68 | + |
| 69 | + /** |
| 70 | + * Set the data point to use as the grouping data source |
| 71 | + */ |
| 72 | + dataSrc?: number|string; |
| 73 | + |
| 74 | + /** |
| 75 | + * Text to show for rows which have `null`, `undefined` or empty string group data |
| 76 | + * |
| 77 | + * @since 1.0.2 |
| 78 | + */ |
| 79 | + emptyDataGroup?: string; |
| 80 | + |
| 81 | + /** |
| 82 | + * Provides the ability to disable row grouping at initialisation |
| 83 | + */ |
| 84 | + enable?: boolean; |
| 85 | + |
| 86 | + /** |
| 87 | + * Set the class name to be used for the grouping end rows |
| 88 | + */ |
| 89 | + endClassName?: string; |
| 90 | + |
| 91 | + /** |
| 92 | + * Provide a function that can be used to control the data shown in the end grouping row |
| 93 | + */ |
| 94 | + endRender?: (rows: Api<any>, group: string) => string|HTMLElement|JQuery; |
| 95 | + |
| 96 | + /** |
| 97 | + * Set the class name to be used for the start grouping rows |
| 98 | + */ |
| 99 | + startClassName?: string; |
| 100 | + |
| 101 | + /** |
| 102 | + * Provide a function that can be used to control the data shown in the start grouping row |
| 103 | + */ |
| 104 | + startRender?: (rows: Api<any>, group: string) => string|HTMLElement|JQuery; |
| 105 | +} |
| 106 | + |
| 107 | + |
| 108 | +interface ApiRowGroup<T> extends Api<T> { |
| 109 | + /** |
| 110 | + * Get the data source for the row grouping |
| 111 | + * |
| 112 | + * @returns Data source property |
| 113 | + */ |
| 114 | + dataSrc(): number | string; |
| 115 | + |
| 116 | + /** |
| 117 | + * Set the data source for the row grouping |
| 118 | + * |
| 119 | + * @param prop Data source property |
| 120 | + * @returns DataTables Api instance |
| 121 | + */ |
| 122 | + dataSrc(prop: number|string): Api<T>; |
| 123 | + |
| 124 | + /** |
| 125 | + * Disable RowGroup's interaction with the table |
| 126 | + * |
| 127 | + * @returns DataTables API instance |
| 128 | + */ |
| 129 | + disable(): Api<T>; |
| 130 | + |
| 131 | + /** |
| 132 | + * Enable or disable RowGroup's interaction with the table |
| 133 | + * |
| 134 | + * @param enable Either enables or disables RowGroup depending on the value of the flag |
| 135 | + * @returns DataTables Api instance |
| 136 | + */ |
| 137 | + enable(enable?: boolean): Api<T>; |
| 138 | + |
| 139 | + /** |
| 140 | + * Get the enabled state for RowGroup. |
| 141 | + * |
| 142 | + * @returns true if enabled, false otherwise |
| 143 | + */ |
| 144 | + enabled(): boolean; |
| 145 | +} |
0 commit comments