@danielgindi/dgtable.js 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +288 -0
- package/connectors/jquery/index.js +27 -0
- package/connectors/jquery/package.json +46 -0
- package/dist/lib.cjs.js +6290 -0
- package/dist/lib.cjs.js.map +1 -0
- package/dist/lib.cjs.min.js +7 -0
- package/dist/lib.cjs.min.js.map +1 -0
- package/dist/lib.es6.js +6288 -0
- package/dist/lib.es6.js.map +1 -0
- package/dist/lib.es6.min.js +7 -0
- package/dist/lib.es6.min.js.map +1 -0
- package/dist/lib.umd.js +4365 -0
- package/dist/lib.umd.js.map +1 -0
- package/dist/lib.umd.min.js +7 -0
- package/dist/lib.umd.min.js.map +1 -0
- package/eslint.config.mjs +133 -0
- package/package.json +55 -0
- package/src/SelectionHelper.js +65 -0
- package/src/by_column_filter.js +25 -0
- package/src/column_collection.js +153 -0
- package/src/index.js +4003 -0
- package/src/row_collection.js +183 -0
- package/src/util.js +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Daniel Cohen Gindi (danielgindi@gmail.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
DGTable.js
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
This is a table View for vanilla JS, which is meant to be high-performance, and allow simple user interactions with the UI, such as:
|
|
5
|
+
* Sorting
|
|
6
|
+
* Sorting by more than one column
|
|
7
|
+
* Moving columns
|
|
8
|
+
* Resizing columns
|
|
9
|
+
* Full cell preview when hovering
|
|
10
|
+
* Native RTL support
|
|
11
|
+
* Variable row height
|
|
12
|
+
|
|
13
|
+
Other features implemented are:
|
|
14
|
+
* Mix absolute column widths with relative column widths
|
|
15
|
+
* Virtual table mode (to supply high performance with hundreds of thousands of rows). This is the default.
|
|
16
|
+
* Non-virtual table mode is fully supported, but for giant amounts of data it is not recommended.
|
|
17
|
+
* Option to set a fixed width for the table so resizing (relative) columns will still make sure the table will not be less (and/or more) than the specified width.
|
|
18
|
+
* Option to have both scrollbars inside the table. (set `width: DGTable.Width.SCROLL`)
|
|
19
|
+
|
|
20
|
+
`jquery.dgtable` users:
|
|
21
|
+
* Older `jquery.dgtable` can either keep using `jquery.dgtable`, or migrate to this new version which is more lightweight.
|
|
22
|
+
* The new version's API is the same as the old one, except that:
|
|
23
|
+
* No `$el` property
|
|
24
|
+
* No auto-clear of jQuery data.
|
|
25
|
+
* There is now an `emit` method instead of `trigger`.
|
|
26
|
+
* Event arguments are now always a single value/object.
|
|
27
|
+
* Props on DOM elements are now: `'columnName'` on a cell, `'index'/'vIndex'` on a row, `'columnName'/rowIndex'/'rowVIndex'` on a cellPreview
|
|
28
|
+
|
|
29
|
+
My TODO list:
|
|
30
|
+
* TODO: Have a simple and accurate API documentation here in the readme
|
|
31
|
+
|
|
32
|
+
## Dev environment
|
|
33
|
+
|
|
34
|
+
* Using grunt over Node.js to automate validating and building.
|
|
35
|
+
* After installing Node.js, use `npm install`, and `npm install -g grunt-cli` to prepare building environment.
|
|
36
|
+
* Use `grunt style` to just test for correct styling.
|
|
37
|
+
* Use `grunt build` or just `grunt` to compile for release.
|
|
38
|
+
* I am using Google Closure Compiler, because UglifyJS does not work with the JSDoc, and there's a major difference in size & performance of the output code.
|
|
39
|
+
* Some features of jshint are disabled because it does not work well with JSDoc which is used for Google Closue Compiler.
|
|
40
|
+
* Indentations in my editor are set to 4 spaces, and jshint validates that.
|
|
41
|
+
|
|
42
|
+
## Me
|
|
43
|
+
* Hi! I am Daniel Cohen Gindi. Or in short- Daniel.
|
|
44
|
+
* danielgindi@gmail.com is my email address.
|
|
45
|
+
* That's all you need to know.
|
|
46
|
+
|
|
47
|
+
## Help
|
|
48
|
+
|
|
49
|
+
I have invested, and investing, a lot of time in this project.
|
|
50
|
+
If you want to help, you could:
|
|
51
|
+
* Actually code, and issue pull requests
|
|
52
|
+
* Test the library under different conditions and browsers
|
|
53
|
+
* Create more demo pages
|
|
54
|
+
* Spread the word
|
|
55
|
+
*
|
|
56
|
+
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G22LPLJ79NBYQ)
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
To create a new table, just use `var myTable = new DGTable(INIT_OPTIONS)`.
|
|
61
|
+
|
|
62
|
+
#### `INIT_OPTIONS`
|
|
63
|
+
|
|
64
|
+
* **columns**: `COLUMN_OPTIONS[]` (Array of COLUMN_OPTIONS objects)
|
|
65
|
+
* **name**: `string` Name of the column
|
|
66
|
+
* **label**: `string=name` Used for the header of this column
|
|
67
|
+
* **dataPath**: `string=name` Path to the data to show (Defaults to `name`)
|
|
68
|
+
* **comparePath**: `string=name` Path to the data to use for comparison (Defaults to `dataPath`)
|
|
69
|
+
* **width**: `number|string`
|
|
70
|
+
* A simple number (i.e `10`, `30`, `50`) will set an absolute width for the column.
|
|
71
|
+
* A percentage (i.e `'30%'`) or a 0-1 decimal value (i.e `0.2`, `0.7`) will set a relative width for the column, out of the full table's width.
|
|
72
|
+
* Any other value, like `0`, `null` etc. will set an automatic width mode, base of the header's content length.
|
|
73
|
+
* **resizable**: `boolean=true` Is this column resizable?
|
|
74
|
+
* **sortable**: `boolean=true` Is this column sortable?
|
|
75
|
+
* **movable**: `boolean=true` Is this column movable?
|
|
76
|
+
* **visible**: `boolean=true` Is this column visible?
|
|
77
|
+
* **cellClasses**: `string` Classes to add to the DOM element of this cell
|
|
78
|
+
* **ignoreMin**: `boolean=false` Should this column ignore the minimum width specified for the table columns?
|
|
79
|
+
* **height**: `number` Suggested height for the table
|
|
80
|
+
* **width**: `DGTable.Width=DGTable.Width.NONE` The way that the width of the table will be handled
|
|
81
|
+
* `DGTable.Width.NONE`: No special handling
|
|
82
|
+
* `DGTable.Width.AUTO`: Sets the width automatically
|
|
83
|
+
* `DGTable.Width.SCROLL`: Creates a horizontal scroll when required
|
|
84
|
+
* **virtualTable**: `boolean=true` When set, the table will work in virtual mode, which means only the visible rows are rendered. Rows must have fixed height in this mode.
|
|
85
|
+
* **estimatedRowHeight**: `number?` Sets the estimated row height for the table. This is used for virtual table mode, to calculate the estimated scroll size. Will be auto calculated by default.
|
|
86
|
+
* **resizableColumns**: `boolean=true` Turns on or off the resizable columns globally.
|
|
87
|
+
* **movableColumns**: `boolean=true` Turns on or off the movable columns globally.
|
|
88
|
+
* **sortableColumns**: `number=1` How many columns can you sort by, one after another?
|
|
89
|
+
* **adjustColumnWidthForSortArrow**: `boolean=true` When set, the columns will automatically grow to accommodate for the sort arrow.
|
|
90
|
+
* **relativeWidthGrowsToFillWidth**: `boolean=true` When set, relative width columns automatically grow to fill the table's width.
|
|
91
|
+
* **relativeWidthShrinksToFillWidth**: `boolean=false` When set, relative width columns automatically shrink to fill the table's width.
|
|
92
|
+
* **convertColumnWidthsToRelative**: `boolean=false` When set, auto-width columns are automatically converted to relatives.
|
|
93
|
+
* **autoFillTableWidth**: `boolean=false` When set, columns are stretched proportionally to fill the table width (only if there is space left). Will supersede `relativeWidthGrowsToFillWidth` in the future.
|
|
94
|
+
* **allowCancelSort**: `boolean=true` When set, the sorting arrows will have 3 modes - asc, desc, and cancelled.
|
|
95
|
+
* **cellClasses**: `string` Classes to add to the DOM element of all cells
|
|
96
|
+
* **sortColumn**: `string|string[]|COLUMN_SORT_OPTIONS|COLUMN_SORT_OPTIONS[]` Columns to sort by
|
|
97
|
+
* Can be a column or an array of columns.
|
|
98
|
+
* Each column is a `string` or a `COLUMN_SORT_OPTIONS`:
|
|
99
|
+
* **column**: `string` Column name
|
|
100
|
+
* **descending**: `boolean=false` Is this column sorted in descending order?
|
|
101
|
+
* **cellFormatter**: `Function(string value, string columnName, Object rowData)string` *(optional)* A formatter function which will return the HTML for the cell. By default the formatter is a plain HTML formatter.
|
|
102
|
+
* **headerCellFormatter**: `Function(string value, string columnName)string` *(optional)* A formatter function which will return the HTML for the cell's header. By default the formatter is a plain HTML formatter.
|
|
103
|
+
* **rowsBufferSize**: `number=10` The size of the rows buffer, for virtual table
|
|
104
|
+
* **minColumnWidth**: `number=35` In pixels, the minimum width for a column
|
|
105
|
+
* **resizeAreaWidth**: `number=8` The size of the area where you can drag to resize.
|
|
106
|
+
* **onComparatorRequired**: `function(columnName: string, descending: boolean, defaultComparator: function(a,b):number):{function(a,b):number}` A callback that can pass a comparator function for each column and mode as required.
|
|
107
|
+
* **resizerClassName**: `string='dgtable-resize'` Class name for the dragged resizing element (showing when resizing a column)
|
|
108
|
+
* **tableClassName**: `string='dgtable'` Class name for the table
|
|
109
|
+
* **allowCellPreview**: `boolean=true` When set, hovering on truncated cells will show a preview of the full content.
|
|
110
|
+
* **allowHeaderCellPreview**: `boolean=true` Allow for toggling off **allowCellPreview** for headers specifically.
|
|
111
|
+
* **cellPreviewAutoBackground**: `boolean=true` When set, the preview cell will receive its background automatically from the cell.
|
|
112
|
+
* **cellPreviewClassName**: `string='dgtable-cell-preview'` Class name for the cell preview element
|
|
113
|
+
* **className**: `string='dgtable-wrapper'` Element class name.
|
|
114
|
+
* **el**: `Element?` Optional element to take over
|
|
115
|
+
* **filter**: `Function(row: Object, args: Object): boolean` *(optional)* A filter function for using with the `filter` method
|
|
116
|
+
|
|
117
|
+
#### Events triggered by DGTable:
|
|
118
|
+
|
|
119
|
+
* `renderskeleton`: The table is re-drawing it's base elements, including headers. Will always be followed by a `render` event.
|
|
120
|
+
* `render`: The table has finished rendering (after adding rows etc.).
|
|
121
|
+
* `cellpreview`: We are about to show a cell preview - `{ el: Element, rowIndex: number|null, name: string, rowData: Object|null, cell: Element, cellEl: Element }`
|
|
122
|
+
* At this stage you can prevent showing the preview, by calling `table.hideCellPreview`
|
|
123
|
+
* `cellpreviewdestroy`: Cell preview element is about to be destroyed after hiding - `{ el: Element, name: string, filteredRowIndex: number|null, rowIndex: Object|null, cell: Element, cellEl: Element }`
|
|
124
|
+
* You can use this event to release any resources that you may have used in `cellPreview` event.
|
|
125
|
+
* `headerrowcreate`: The header row has just been created - `Element`
|
|
126
|
+
* `headerrowdestroy`: Called just before removing the header row DOM element from the table - `Element`
|
|
127
|
+
* `rowcreate`: A row has just been created - `{ filteredRowIndex: number, rowIndex: number, rowEl: Element, rowData: Object }`
|
|
128
|
+
* `rowclick`: A row has just been created - `{ event: MouseEvent, rowIndex: number, rowIndex: number, rowEl: Element, rowData: Object }`
|
|
129
|
+
* `rowdestroy`: Called just before removing a row DOM element from the table - `Element`
|
|
130
|
+
* `addrows`: Data rows have been added to the table - `({ count: number, clear: boolean })`
|
|
131
|
+
* `addcolumn`: A column was added - `string` (the column's name)
|
|
132
|
+
* `removecolumn`: A column was removed - `string` (the column's name)
|
|
133
|
+
* `movecolumn`: A column was moved - `({ name: string, src: number, dest: number })`
|
|
134
|
+
* `showcolumn`: A column was shown - `string` (the column's name)
|
|
135
|
+
* `hidecolumn`: A column was hidden - `string` (the column's name)
|
|
136
|
+
* `columnwidth`: A column was resized - `({ name: string, width: number|string, oldWidth: number|string })`
|
|
137
|
+
* `filter`: A filter was applied - `any` - the arguments passed to the filter method
|
|
138
|
+
* `filterclear`: A filter was cleared
|
|
139
|
+
* `sort`: The data was sorted - `{ sorts: { "column": "column's name", "descending": true|false }[], resort: true|undefined, comparator: Function }`
|
|
140
|
+
* `headercontextmenu`: A context menu should be shown for a header cell - `({ name: string, pageX: number, pageY: number, bounds: { left: number, top: number, width: number, height: number } })`
|
|
141
|
+
|
|
142
|
+
- Member functions:
|
|
143
|
+
* `on(eventName, {Function?} callback)`: Adds an event listener
|
|
144
|
+
* `once(eventName, {Function?} callback)`: Adds a one-shot event listener
|
|
145
|
+
* `off(eventName, {Function?} callback)`: Removes an event listener
|
|
146
|
+
* `render()`: Renders the view. Should be called after adding to the DOM, and when the viewport has changed and the table has no knowledge of it.
|
|
147
|
+
* `clearAndRender({boolean} render = true)`: Forces a full render of the table
|
|
148
|
+
* `setColumns({COLUMN_OPTIONS[]} columns, {boolean} render = true) {DGTable}`: Sets the table columns
|
|
149
|
+
* `addColumn({COLUMN_OPTIONS} columnData, {string|number} before = -1, {boolean} render = true) {DGTable}`: Add a column to the table
|
|
150
|
+
* **columnData**: Column properties. Same manner as in the **columns** options when initializing the DGTable
|
|
151
|
+
* **before**: Column name or order to be inserted before.
|
|
152
|
+
* *returns* Self, to allow for call chaining.
|
|
153
|
+
* `removeColumn({string} column, {boolean} render = true) {DGTable}`: Remove a column from the table
|
|
154
|
+
* **column**: Column name
|
|
155
|
+
* *returns* Self, to allow for call chaining.
|
|
156
|
+
* `setFilter({Function(row: Object, args: Object): boolean} filterFunc) {DGTable}`: Sets a new filtering function, set null for default.
|
|
157
|
+
* **filterFunc**: The filtering function receives a row and an options object, and returns true for any row that passes the filter.
|
|
158
|
+
* *returns* Self, to allow for call chaining.
|
|
159
|
+
* `setCellFormatter({Function(value: *, columnName: string, row: Object):string|null} formatter) {DGTable}`: Sets a new cell formatter.
|
|
160
|
+
* **formatter**: The cell formatter. Should return an HTML.
|
|
161
|
+
* *returns* Self, to allow for call chaining.
|
|
162
|
+
* `setHeaderCellFormatter({Function(label: string, columnName: string):string|null} formatter) {DGTable}`: Sets a new header cell formatter.
|
|
163
|
+
* **formatter**: The cell formatter. Should return an HTML.
|
|
164
|
+
* *returns* Self, to allow for call chaining.
|
|
165
|
+
* `filter({Object} args) {DGTable}`: Filter the visible rows in the table
|
|
166
|
+
* **args**: Options to pass to the filtering function
|
|
167
|
+
* *returns* Self, to allow for call chaining.
|
|
168
|
+
* `filter({{column: string, keyword: string, caseSensitive: boolean}} args) {DGTable}`: Syntax for default filtering function.
|
|
169
|
+
* **args.column**: Name of the column to filter on
|
|
170
|
+
* **args.keyword**: Tests the specified column if contains this keyword
|
|
171
|
+
* **args.caseSensitive**: Use caseSensitive filtering
|
|
172
|
+
* *returns* Self, to allow for call chaining.
|
|
173
|
+
* `clearFilter() {DGTable}`: Clears the current filter
|
|
174
|
+
* *returns* Self, to allow for call chaining.
|
|
175
|
+
* `setColumnLabel({string} column, {string} label) {DGTable}`: Set a new label to a column
|
|
176
|
+
* **column**: Name of the column
|
|
177
|
+
* **label**: New label for the column
|
|
178
|
+
* *returns* Self, to allow for call chaining.
|
|
179
|
+
* `moveColumn({string|number} src, {string|number} dest, visibleOnly = true) {DGTable}`: Move a column to a new position
|
|
180
|
+
* **src**: Name or position of the column to be moved
|
|
181
|
+
* **dest**: Name of the column currently in the desired position, or the position itself
|
|
182
|
+
* **visibleOnly**: Should consider only visible columns and visible-relative indexes
|
|
183
|
+
* *returns* Self, to allow for call chaining.
|
|
184
|
+
* `sort({string?} column, {boolean?} descending, {boolean=false} add) {DGTable}`: Sort the table. This does not render automatically, so you may need to call render() too.
|
|
185
|
+
* **src**: Name of the column to sort on
|
|
186
|
+
* **descending**: Sort in descending order (if not specified, defaults to false or reverses current descending mode if sorting by same column)
|
|
187
|
+
* **add**: Should this sort be on top of the existing sort? (For multiple column sort)
|
|
188
|
+
* *returns* Self, to allow for call chaining.
|
|
189
|
+
* `resort() {DGTable}`: Re-sort the table using current sort specifiers. This does not render automatically, so you may need to call render() too.
|
|
190
|
+
* *returns* Self, to allow for call chaining.
|
|
191
|
+
* `setColumnVisible({string} column, {boolean} visible) {DGTable}`: Show or hide a column
|
|
192
|
+
* **column**: Unique column name
|
|
193
|
+
* **visible**: New visibility mode for the column
|
|
194
|
+
* *returns* Self, to allow for call chaining.
|
|
195
|
+
* `isColumnVisible({string} column, {boolean} visible) {boolean}`: Get the visibility mode of a column
|
|
196
|
+
* *returns* True if visible
|
|
197
|
+
* `setMinColumnWidth({number} minColumnWidth) {DGTable}`: Globally set the minimum column width
|
|
198
|
+
* **minColumnWidth**: Minimum column width
|
|
199
|
+
* *returns* Self, to allow for call chaining.
|
|
200
|
+
* `getMinColumnWidth() {number}`: Get the current minimum column width
|
|
201
|
+
* *returns* Minimum column width
|
|
202
|
+
* `setSortableColumns({number} sortableColumns) {DGTable}`: Set the limit on concurrent columns sortedh
|
|
203
|
+
* **sortableColumns**: Minimum column width
|
|
204
|
+
* *returns* Self, to allow for call chaining.
|
|
205
|
+
* `getSortableColumns() {number}`: Get the limit on concurrent columns sorted
|
|
206
|
+
* *returns* How many sortable columns are allowed?
|
|
207
|
+
* `getHeaderRowElement() {Element}`: Get the DOM element of the header row
|
|
208
|
+
* *returns* a DOM element
|
|
209
|
+
* `setMovableColumns({boolean} movableColumns) {DGTable}`: *Undocumented yet*
|
|
210
|
+
* `getMovableColumns() {boolean}`: *Undocumented yet*
|
|
211
|
+
* `setResizableColumns({boolean} resizableColumns) {DGTable}`: *Undocumented yet*
|
|
212
|
+
* `getResizableColumns() {boolean}`: *Undocumented yet*
|
|
213
|
+
* `setOnComparatorRequired({function(columnName: string, descending: boolean, defaultComparator: function(a,b):number):{function(a,b):number}}|null comparatorCallback) {DGTable}`: Sets a functions that supplies comparators dynamically
|
|
214
|
+
* **comparatorCallback**: a function that returns the comparator for a specific column
|
|
215
|
+
* `setCustomSortingProvider({{function(data: any[], sort: function(any[]):any[]):any[]}|null} customSortingProvider) {DGTable}`: sets custom sorting function for a data set
|
|
216
|
+
* **customSortingProvider**: provides a custom sorting function (not the comparator, but a sort() alternative) for a data set
|
|
217
|
+
* `setColumnWidth({string} column, {number|string} width) {DGTable}`: *Undocumented yet*
|
|
218
|
+
* `getColumnWidth({string} column) {string|null}`: *Undocumented yet*
|
|
219
|
+
* `getColumnConfig({string} column name) {SERIALIZED_COLUMN}`: *Undocumented yet*
|
|
220
|
+
* `getColumnsConfig() {Object}`: *Undocumented yet*
|
|
221
|
+
* `getSortedColumns() {Array.<SERIALIZED_COLUMN_SORT>}`: *Undocumented yet*
|
|
222
|
+
* `getHtmlForRowCell(row: number, columnName: string) {string}`: Returns the HTML for specified cell in a row.
|
|
223
|
+
* **row**: Index of row
|
|
224
|
+
* **columnName**: Name of cell
|
|
225
|
+
* *returns* HTML for cell. By default cell content is *not* HTML encoded, you should encode appropriately in your `cellFormatter`.
|
|
226
|
+
* `getHtmlForRowDataCell(rowData: Object, columnName: string) {string|null}`: Returns the HTML string for a specific cell. Can be used externally for special cases (i.e. when setting a fresh HTML in the cell preview through the callback).
|
|
227
|
+
* **rowData**: Actual row data
|
|
228
|
+
* **columnName**: Name of column
|
|
229
|
+
* *returns* string for the specified cell
|
|
230
|
+
* `getDataForRow(rowIndex: number): Object`: Gets the row data for a specific row
|
|
231
|
+
* *returns* row data at the specified index, out of all rows (not filtered)
|
|
232
|
+
* `getRowCount(): number`: Gets the number of rows
|
|
233
|
+
* *returns* the number of rows
|
|
234
|
+
* `getIndexForRow(row: Object): number`: Finds the index of the specified row
|
|
235
|
+
* *returns* the index of the specified row
|
|
236
|
+
* `getFilteredRowCount(): number`: Gets the number of filtered rows
|
|
237
|
+
* *returns* the number of rows in the filtered set (defaults to full row count if no filtering is active)
|
|
238
|
+
* `getIndexForFilteredRow(row: Object): number`: Finds the index of the specified row within the filtered results
|
|
239
|
+
* *returns* the index of the specified row
|
|
240
|
+
* `getDataForFilteredRow(row: number): Object`: *Undocumented yet*
|
|
241
|
+
* `getRowElement(rowIndex: number): Element`: Returns the element of the specified row (unfiltered index)
|
|
242
|
+
* `getRowYPos(rowIndex: number): number?`: Returns the Y pos of the specified row (unfiltered index)
|
|
243
|
+
* `tableWidthChanged() {DGTable}`: *Undocumented yet*
|
|
244
|
+
* `tableHeightChanged() {DGTable}`: *Undocumented yet*
|
|
245
|
+
* `addRows({Object[]} data, {number} at = -1, {boolean} resort = false, {boolean} render = true) {DGTable}`: Adds the specified rows at the specified position, and optionally resorts the data
|
|
246
|
+
* `removeRow({number} rowIndex, {boolean} render = true) {DGTable}`: Removes one row at the specified position
|
|
247
|
+
* `removeRows({number} rowIndex, {number} count, {boolean} render = true) {DGTable}`: Removes rows at the specified position
|
|
248
|
+
* `refreshRow({number} rowIndex) {DGTable}`: Refreshes the row specified
|
|
249
|
+
* *returns* Self
|
|
250
|
+
* `refreshAllVirtualRows() {DGTable}`: Refreshes all virtual rows
|
|
251
|
+
* *returns* Self
|
|
252
|
+
* `setRows(data: Object[], resort: boolean=false) {DGTable}`: Rests the table rows to the provided array of rows.
|
|
253
|
+
* **data**: New rows for the table
|
|
254
|
+
* **resort**: Should re-sort the table?
|
|
255
|
+
* *returns* Self, to allow for call chaining.
|
|
256
|
+
* `getUrlForElementContent({string} id) {string?}`: *Undocumented yet*
|
|
257
|
+
* `isWorkerSupported() {boolean}`: *Undocumented yet*
|
|
258
|
+
* `createWebWorker({string} url) {Worker?}`: *Undocumented yet*
|
|
259
|
+
* `unbindWebWorker({Worker} worker) {DGTable}`: *Undocumented yet*
|
|
260
|
+
* `hideCellPreview() {DGTable}`: Hide any cell preview showing currently, or prevent showing a cell preview from within the `cellpreview` event.
|
|
261
|
+
* `destroy()`: Destroy the table and free all of its memory.
|
|
262
|
+
|
|
263
|
+
## License
|
|
264
|
+
|
|
265
|
+
All the code here is under MIT license. Which means you could do virtually anything with the code.
|
|
266
|
+
I will appreciate it very much if you keep an attribution where appropriate.
|
|
267
|
+
|
|
268
|
+
The MIT License (MIT)
|
|
269
|
+
|
|
270
|
+
Copyright (c) 2013 Daniel Cohen Gindi (danielgindi@gmail.com)
|
|
271
|
+
|
|
272
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
273
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
274
|
+
in the Software without restriction, including without limitation the rights
|
|
275
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
276
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
277
|
+
furnished to do so, subject to the following conditions:
|
|
278
|
+
|
|
279
|
+
The above copyright notice and this permission notice shall be included in all
|
|
280
|
+
copies or substantial portions of the Software.
|
|
281
|
+
|
|
282
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
283
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
284
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
285
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
286
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
287
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
288
|
+
SOFTWARE.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import jQuery from 'connectors/jquery/index';
|
|
2
|
+
import DGTable from '@danielgindi/dgtable.js';
|
|
3
|
+
|
|
4
|
+
export class DGTableJQuery extends DGTable {
|
|
5
|
+
constructor(options) {
|
|
6
|
+
super(options);
|
|
7
|
+
|
|
8
|
+
this.$el = jQuery(this.el)
|
|
9
|
+
.data('dgtable', this)
|
|
10
|
+
.on('remove', () => this.destroy());
|
|
11
|
+
|
|
12
|
+
this.on('headerrowdestroy', () => {
|
|
13
|
+
const headerRow = this._p?.headerRow;
|
|
14
|
+
if (!headerRow) return;
|
|
15
|
+
|
|
16
|
+
jQuery(headerRow).find(`div.${this._o.tableClassName}-header-cell`).remove();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
destroy() {
|
|
21
|
+
if (this._p?.table)
|
|
22
|
+
jQuery(this._p.table).empty();
|
|
23
|
+
if (this._p?.tbody)
|
|
24
|
+
jQuery(this._p.tbody).empty();
|
|
25
|
+
return super.destroy();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jquery.dgtable",
|
|
3
|
+
"description": "High-performance table View for jQuery",
|
|
4
|
+
"version": "0.6.19",
|
|
5
|
+
"main": "dist/lib.cjs.min.js",
|
|
6
|
+
"module": "dist/lib.es6.min.js",
|
|
7
|
+
"broswer": "dist/lib.umd.min.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"author": {
|
|
10
|
+
"name": "Daniel Cohen Gindi",
|
|
11
|
+
"email": "danielgindi@gmail.com"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git://github.com/danielgindi/dgtable.js.git"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "npm run lint && node scripts/build.js",
|
|
19
|
+
"prepublishOnly": "node -e \"process.env.NODE_ENV != 'production' && process.exit(1)\" || npm run build"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/danielgindi/dgtable.js/issues"
|
|
23
|
+
},
|
|
24
|
+
"licenses": [
|
|
25
|
+
{
|
|
26
|
+
"type": "MIT",
|
|
27
|
+
"url": "https://github.com/danielgindi/dgtable.js/blob/master/LICENSE"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@danielgindi/dgtable.js": "^2.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@babel/core": "^7.28.5",
|
|
35
|
+
"@babel/preset-env": "^7.28.5",
|
|
36
|
+
"@babel/runtime": "^7.28.4",
|
|
37
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
38
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
39
|
+
"core-js": "^3.47.0",
|
|
40
|
+
"fs-extra": "^11.3.2",
|
|
41
|
+
"globals": "^15",
|
|
42
|
+
"husky": "^9.1.7",
|
|
43
|
+
"pinst": "^3.0.0",
|
|
44
|
+
"rollup": "^4.53.3"
|
|
45
|
+
}
|
|
46
|
+
}
|