jquery.dgtable 0.5.59 → 0.6.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/README.md +83 -82
- package/dist/jquery.dgtable.cjs.js +1868 -793
- package/dist/jquery.dgtable.cjs.js.map +1 -1
- package/dist/jquery.dgtable.cjs.min.js +2 -2
- package/dist/jquery.dgtable.cjs.min.js.map +1 -1
- package/dist/jquery.dgtable.es6.js +1869 -794
- package/dist/jquery.dgtable.es6.js.map +1 -1
- package/dist/jquery.dgtable.es6.min.js +2 -2
- package/dist/jquery.dgtable.es6.min.js.map +1 -1
- package/dist/jquery.dgtable.umd.js +6042 -4459
- package/dist/jquery.dgtable.umd.js.map +1 -1
- package/dist/jquery.dgtable.umd.min.js +2 -2
- package/dist/jquery.dgtable.umd.min.js.map +1 -1
- package/package.json +12 -11
- package/src/column_collection.js +7 -7
- package/src/index.js +342 -624
- package/src/css_util.js +0 -24
package/README.md
CHANGED
|
@@ -8,6 +8,7 @@ This is a table View for jQuery, which is meant to be high-performance, and allo
|
|
|
8
8
|
* Resizing columns
|
|
9
9
|
* Full cell preview when hovering
|
|
10
10
|
* Native RTL support
|
|
11
|
+
* Variable row height
|
|
11
12
|
|
|
12
13
|
Other features implemented are:
|
|
13
14
|
* Mix absolute column widths with relative column widths
|
|
@@ -18,7 +19,6 @@ Other features implemented are:
|
|
|
18
19
|
|
|
19
20
|
A few notes:
|
|
20
21
|
* TODO: Have a simple and accurate API documentation here in the readme
|
|
21
|
-
* Currently in virtual table mode - I cannot handle variable height rows.
|
|
22
22
|
|
|
23
23
|
## Dev environment
|
|
24
24
|
|
|
@@ -53,55 +53,56 @@ To create a new table, just use `var myTable = new DGTable(INIT_OPTIONS)`.
|
|
|
53
53
|
#### `INIT_OPTIONS`
|
|
54
54
|
|
|
55
55
|
* **columns**: `COLUMN_OPTIONS[]` (Array of COLUMN_OPTIONS objects)
|
|
56
|
-
* **name**: `
|
|
57
|
-
* **label**: `
|
|
58
|
-
* **dataPath**: `
|
|
59
|
-
* **comparePath**: `
|
|
60
|
-
* **width**: `
|
|
56
|
+
* **name**: `string` Name of the column
|
|
57
|
+
* **label**: `string=name` Used for the header of this column
|
|
58
|
+
* **dataPath**: `string=name` Path to the data to show (Defaults to `name`)
|
|
59
|
+
* **comparePath**: `string=name` Path to the data to use for comparison (Defaults to `dataPath`)
|
|
60
|
+
* **width**: `number|string`
|
|
61
61
|
* A simple number (i.e `10`, `30`, `50`) will set an absolute width for the column.
|
|
62
62
|
* 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.
|
|
63
63
|
* Any other value, like `0`, `null` etc. will set an automatic width mode, base of the header's content length.
|
|
64
|
-
* **resizable**: `
|
|
65
|
-
* **sortable**: `
|
|
66
|
-
* **movable**: `
|
|
67
|
-
* **visible**: `
|
|
68
|
-
* **cellClasses**: `
|
|
69
|
-
* **ignoreMin**: `
|
|
70
|
-
* **height**: `
|
|
64
|
+
* **resizable**: `boolean=true` Is this column resizable?
|
|
65
|
+
* **sortable**: `boolean=true` Is this column sortable?
|
|
66
|
+
* **movable**: `boolean=true` Is this column movable?
|
|
67
|
+
* **visible**: `boolean=true` Is this column visible?
|
|
68
|
+
* **cellClasses**: `string` Classes to add to the DOM element of this cell
|
|
69
|
+
* **ignoreMin**: `boolean=false` Should this column ignore the minimum width specified for the table columns?
|
|
70
|
+
* **height**: `number` Suggested height for the table
|
|
71
71
|
* **width**: `DGTable.Width=DGTable.Width.NONE` The way that the width of the table will be handled
|
|
72
72
|
* `DGTable.Width.NONE`: No special handling
|
|
73
73
|
* `DGTable.Width.AUTO`: Sets the width automatically
|
|
74
74
|
* `DGTable.Width.SCROLL`: Creates a horizontal scroll when required
|
|
75
|
-
* **virtualTable**: `
|
|
76
|
-
* **
|
|
77
|
-
* **
|
|
78
|
-
* **
|
|
79
|
-
* **
|
|
80
|
-
* **
|
|
81
|
-
* **
|
|
82
|
-
* **
|
|
83
|
-
* **
|
|
84
|
-
* **
|
|
85
|
-
* **
|
|
75
|
+
* **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.
|
|
76
|
+
* **estimatedRowHeight**: `number=40` Sets the estimated row height for the table. This is used for virtual table mode, to calculate the estimated scroll size.
|
|
77
|
+
* **resizableColumns**: `boolean=true` Turns on or off the resizable columns globally.
|
|
78
|
+
* **movableColumns**: `boolean=true` Turns on or off the movable columns globally.
|
|
79
|
+
* **sortableColumns**: `number=1` How many columns can you sort by, one after another?
|
|
80
|
+
* **adjustColumnWidthForSortArrow**: `boolean=true` When set, the columns will automatically grow to accommodate for the sort arrow.
|
|
81
|
+
* **relativeWidthGrowsToFillWidth**: `boolean=true` When set, relative width columns automatically grow to fill the table's width.
|
|
82
|
+
* **relativeWidthShrinksToFillWidth**: `boolean=false` When set, relative width columns automatically shrink to fill the table's width.
|
|
83
|
+
* **convertColumnWidthsToRelative**: `boolean=false` When set, auto-width columns are automatically converted to relatives.
|
|
84
|
+
* **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.
|
|
85
|
+
* **cellClasses**: `string` Classes to add to the DOM element of all cells
|
|
86
|
+
* **sortColumn**: `string|string[]|COLUMN_SORT_OPTIONS|COLUMN_SORT_OPTIONS[]` Columns to sort by
|
|
86
87
|
* Can be a column or an array of columns.
|
|
87
|
-
* Each column is a `
|
|
88
|
-
* **column**: `
|
|
89
|
-
* **descending**: `
|
|
90
|
-
* **cellFormatter**: `Function(
|
|
91
|
-
* **headerCellFormatter**: `Function(
|
|
92
|
-
* **rowsBufferSize**: `
|
|
93
|
-
* **minColumnWidth**: `
|
|
94
|
-
* **resizeAreaWidth**: `
|
|
88
|
+
* Each column is a `string` or a `COLUMN_SORT_OPTIONS`:
|
|
89
|
+
* **column**: `string` Column name
|
|
90
|
+
* **descending**: `boolean=false` Is this column sorted in descending order?
|
|
91
|
+
* **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.
|
|
92
|
+
* **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.
|
|
93
|
+
* **rowsBufferSize**: `number=10` The size of the rows buffer, for virtual table
|
|
94
|
+
* **minColumnWidth**: `number=35` In pixels, the minimum width for a column
|
|
95
|
+
* **resizeAreaWidth**: `number=8` The size of the area where you can drag to resize.
|
|
95
96
|
* **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.
|
|
96
|
-
* **resizerClassName**: `
|
|
97
|
-
* **tableClassName**: `
|
|
98
|
-
* **allowCellPreview**: `
|
|
99
|
-
* **allowHeaderCellPreview**: `
|
|
100
|
-
* **cellPreviewAutoBackground**: `
|
|
101
|
-
* **cellPreviewClassName**: `
|
|
102
|
-
* **className**: `
|
|
97
|
+
* **resizerClassName**: `string='dgtable-resize'` Class name for the dragged resizing element (showing when resizing a column)
|
|
98
|
+
* **tableClassName**: `string='dgtable'` Class name for the table
|
|
99
|
+
* **allowCellPreview**: `boolean=true` When set, hovering on truncated cells will show a preview of the full content.
|
|
100
|
+
* **allowHeaderCellPreview**: `boolean=true` Allow for toggling off **allowCellPreview** for headers specifically.
|
|
101
|
+
* **cellPreviewAutoBackground**: `boolean=true` When set, the preview cell will receive its background automatically from the cell.
|
|
102
|
+
* **cellPreviewClassName**: `string='dgtable-cell-preview'` Class name for the cell preview element
|
|
103
|
+
* **className**: `string='dgtable-wrapper'` Element class name.
|
|
103
104
|
* **el**: `Element?` Optional element to take over
|
|
104
|
-
* **filter**: `Function(row: Object, args: Object):
|
|
105
|
+
* **filter**: `Function(row: Object, args: Object): boolean` *(optional)* A filter function for using with the `filter` method
|
|
105
106
|
|
|
106
107
|
#### Events triggered by DGTable:
|
|
107
108
|
|
|
@@ -161,7 +162,7 @@ To create a new table, just use `var myTable = new DGTable(INIT_OPTIONS)`.
|
|
|
161
162
|
* `filterclear`: A filter was cleared
|
|
162
163
|
* `sort`: The data was sorted
|
|
163
164
|
* 1st argument: `Array` of sort constructs `[{ "column": "column's name", "descending": true/false }, ...]`
|
|
164
|
-
* 2nd argument: `
|
|
165
|
+
* 2nd argument: `boolean` that determines whether this is a primary sort or a resort (sort()/header click, vs resort(), addRows(), etc.). If `true`, this is a resort.
|
|
165
166
|
* 3rd argument: `Function` - the comparator that was used to sort.
|
|
166
167
|
* `headercontextmenu`: A context menu should be shown for a header cell
|
|
167
168
|
* 1st argument: The column's name
|
|
@@ -174,114 +175,114 @@ To create a new table, just use `var myTable = new DGTable(INIT_OPTIONS)`.
|
|
|
174
175
|
* `once(eventName, {Function?} callback)`: Adds a one-shot event listener
|
|
175
176
|
* `off(eventName, {Function?} callback)`: Removes an event listener
|
|
176
177
|
* `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.
|
|
177
|
-
* `clearAndRender({
|
|
178
|
-
* `setColumns({COLUMN_OPTIONS[]} columns, {
|
|
179
|
-
* `addColumn({COLUMN_OPTIONS} columnData, {
|
|
178
|
+
* `clearAndRender({boolean} render = true)`: Forces a full render of the table
|
|
179
|
+
* `setColumns({COLUMN_OPTIONS[]} columns, {boolean} render = true) {DGTable}`: Sets the table columns
|
|
180
|
+
* `addColumn({COLUMN_OPTIONS} columnData, {string|number} before = -1, {boolean} render = true) {DGTable}`: Add a column to the table
|
|
180
181
|
* **columnData**: Column properties. Same manner as in the **columns** options when initializing the DGTable
|
|
181
182
|
* **before**: Column name or order to be inserted before.
|
|
182
183
|
* *returns* Self, to allow for call chaining.
|
|
183
|
-
* `removeColumn({
|
|
184
|
+
* `removeColumn({string} column, {boolean} render = true) {DGTable}`: Remove a column from the table
|
|
184
185
|
* **column**: Column name
|
|
185
186
|
* *returns* Self, to allow for call chaining.
|
|
186
|
-
* `setFilter({Function(row: Object, args: Object):
|
|
187
|
+
* `setFilter({Function(row: Object, args: Object): boolean} filterFunc) {DGTable}`: Sets a new filtering function, set null for default.
|
|
187
188
|
* **filterFunc**: The filtering function receives a row and an options object, and returns true for any row that passes the filter.
|
|
188
189
|
* *returns* Self, to allow for call chaining.
|
|
189
|
-
* `setCellFormatter({Function(value: *, columnName:
|
|
190
|
+
* `setCellFormatter({Function(value: *, columnName: string, row: Object):string|null} formatter) {DGTable}`: Sets a new cell formatter.
|
|
190
191
|
* **formatter**: The cell formatter. Should return an HTML.
|
|
191
192
|
* *returns* Self, to allow for call chaining.
|
|
192
|
-
* `setHeaderCellFormatter({Function(label:
|
|
193
|
+
* `setHeaderCellFormatter({Function(label: string, columnName: string):string|null} formatter) {DGTable}`: Sets a new header cell formatter.
|
|
193
194
|
* **formatter**: The cell formatter. Should return an HTML.
|
|
194
195
|
* *returns* Self, to allow for call chaining.
|
|
195
196
|
* `filter({Object} args) {DGTable}`: Filter the visible rows in the table
|
|
196
197
|
* **args**: Options to pass to the filtering function
|
|
197
198
|
* *returns* Self, to allow for call chaining.
|
|
198
|
-
* `filter({{column:
|
|
199
|
+
* `filter({{column: string, keyword: string, caseSensitive: boolean}} args) {DGTable}`: Syntax for default filtering function.
|
|
199
200
|
* **args.column**: Name of the column to filter on
|
|
200
201
|
* **args.keyword**: Tests the specified column if contains this keyword
|
|
201
202
|
* **args.caseSensitive**: Use caseSensitive filtering
|
|
202
203
|
* *returns* Self, to allow for call chaining.
|
|
203
204
|
* `clearFilter() {DGTable}`: Clears the current filter
|
|
204
205
|
* *returns* Self, to allow for call chaining.
|
|
205
|
-
* `setColumnLabel({
|
|
206
|
+
* `setColumnLabel({string} column, {string} label) {DGTable}`: Set a new label to a column
|
|
206
207
|
* **column**: Name of the column
|
|
207
208
|
* **label**: New label for the column
|
|
208
209
|
* *returns* Self, to allow for call chaining.
|
|
209
|
-
* `moveColumn({
|
|
210
|
+
* `moveColumn({string|number} src, {string|number} dest, visibleOnly = true) {DGTable}`: Move a column to a new position
|
|
210
211
|
* **src**: Name or position of the column to be moved
|
|
211
212
|
* **dest**: Name of the column currently in the desired position, or the position itself
|
|
212
213
|
* **visibleOnly**: Should consider only visible columns and visible-relative indexes
|
|
213
214
|
* *returns* Self, to allow for call chaining.
|
|
214
|
-
* `sort({
|
|
215
|
+
* `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.
|
|
215
216
|
* **src**: Name of the column to sort on
|
|
216
217
|
* **descending**: Sort in descending order (if not specified, defaults to false or reverses current descending mode if sorting by same column)
|
|
217
218
|
* **add**: Should this sort be on top of the existing sort? (For multiple column sort)
|
|
218
219
|
* *returns* Self, to allow for call chaining.
|
|
219
220
|
* `resort() {DGTable}`: Re-sort the table using current sort specifiers. This does not render automatically, so you may need to call render() too.
|
|
220
221
|
* *returns* Self, to allow for call chaining.
|
|
221
|
-
* `setColumnVisible({
|
|
222
|
+
* `setColumnVisible({string} column, {boolean} visible) {DGTable}`: Show or hide a column
|
|
222
223
|
* **column**: Unique column name
|
|
223
224
|
* **visible**: New visibility mode for the column
|
|
224
225
|
* *returns* Self, to allow for call chaining.
|
|
225
|
-
* `isColumnVisible({
|
|
226
|
+
* `isColumnVisible({string} column, {boolean} visible) {boolean}`: Get the visibility mode of a column
|
|
226
227
|
* *returns* True if visible
|
|
227
|
-
* `setMinColumnWidth({
|
|
228
|
+
* `setMinColumnWidth({number} minColumnWidth) {DGTable}`: Globally set the minimum column width
|
|
228
229
|
* **minColumnWidth**: Minimum column width
|
|
229
230
|
* *returns* Self, to allow for call chaining.
|
|
230
|
-
* `getMinColumnWidth() {
|
|
231
|
+
* `getMinColumnWidth() {number}`: Get the current minimum column width
|
|
231
232
|
* *returns* Minimum column width
|
|
232
|
-
* `setSortableColumns({
|
|
233
|
+
* `setSortableColumns({number} sortableColumns) {DGTable}`: Set the limit on concurrent columns sortedh
|
|
233
234
|
* **sortableColumns**: Minimum column width
|
|
234
235
|
* *returns* Self, to allow for call chaining.
|
|
235
|
-
* `getSortableColumns() {
|
|
236
|
+
* `getSortableColumns() {number}`: Get the limit on concurrent columns sorted
|
|
236
237
|
* *returns* How many sortable columns are allowed?
|
|
237
238
|
* `getHeaderRowElement() {Element}`: Get the DOM element of the header row
|
|
238
239
|
* *returns* a DOM element
|
|
239
|
-
* `setMovableColumns({
|
|
240
|
-
* `getMovableColumns() {
|
|
241
|
-
* `setResizableColumns({
|
|
242
|
-
* `getResizableColumns() {
|
|
243
|
-
* `setComparatorCallback({Function(
|
|
244
|
-
* `setColumnWidth({
|
|
245
|
-
* `getColumnWidth({
|
|
246
|
-
* `getColumnConfig({
|
|
240
|
+
* `setMovableColumns({boolean} movableColumns) {DGTable}`: *Undocumented yet*
|
|
241
|
+
* `getMovableColumns() {boolean}`: *Undocumented yet*
|
|
242
|
+
* `setResizableColumns({boolean} resizableColumns) {DGTable}`: *Undocumented yet*
|
|
243
|
+
* `getResizableColumns() {boolean}`: *Undocumented yet*
|
|
244
|
+
* `setComparatorCallback({Function(string,boolean)Function(a,b)boolean} comparatorCallback) {DGTable}`: *Undocumented yet*
|
|
245
|
+
* `setColumnWidth({string} column, {number|string} width) {DGTable}`: *Undocumented yet*
|
|
246
|
+
* `getColumnWidth({string} column) {string|null}`: *Undocumented yet*
|
|
247
|
+
* `getColumnConfig({string} column name) {SERIALIZED_COLUMN}`: *Undocumented yet*
|
|
247
248
|
* `getColumnsConfig() {Object}`: *Undocumented yet*
|
|
248
249
|
* `getSortedColumns() {Array.<SERIALIZED_COLUMN_SORT>}`: *Undocumented yet*
|
|
249
|
-
* `getHtmlForRowCell(row:
|
|
250
|
+
* `getHtmlForRowCell(row: number, columnName: string) {string}`: Returns the HTML for specified cell in a row.
|
|
250
251
|
* **row**: Index of row
|
|
251
252
|
* **columnName**: Name of cell
|
|
252
253
|
* *returns* HTML for cell. By default cell content is *not* HTML encoded, you should encode appropriately in your `cellFormatter`.
|
|
253
|
-
* `getHtmlForRowDataCell(rowData: Object, columnName:
|
|
254
|
+
* `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).
|
|
254
255
|
* **rowData**: Actual row data
|
|
255
256
|
* **columnName**: Name of column
|
|
256
257
|
* *returns* string for the specified cell
|
|
257
|
-
* `getDataForRow(row:
|
|
258
|
+
* `getDataForRow(row: number): Object`: Gets the row data for a specific row
|
|
258
259
|
* *returns* row data of the row at physical index **row**
|
|
259
|
-
* `getRowCount():
|
|
260
|
+
* `getRowCount(): number`: Gets the number of rows
|
|
260
261
|
* *returns* the number of rows
|
|
261
|
-
* `getIndexForRow(row: Object):
|
|
262
|
+
* `getIndexForRow(row: Object): number`: Finds the index of the specified row
|
|
262
263
|
* *returns* the index of the specified row
|
|
263
|
-
* `getFilteredRowCount():
|
|
264
|
+
* `getFilteredRowCount(): number`: Gets the number of filtered rows
|
|
264
265
|
* *returns* the number of rows in the filtered set (defaults to full row count if no filtering is active)
|
|
265
|
-
* `getIndexForFilteredRow(row: Object):
|
|
266
|
+
* `getIndexForFilteredRow(row: Object): number`: Finds the index of the specified row within the filtered results
|
|
266
267
|
* *returns* the index of the specified row
|
|
267
|
-
* `getDataForFilteredRow(row:
|
|
268
|
-
* `getRowElement(physicalRowIndex:
|
|
269
|
-
* `getRowYPos(physicalRowIndex:
|
|
268
|
+
* `getDataForFilteredRow(row: number): Object`: *Undocumented yet*
|
|
269
|
+
* `getRowElement(physicalRowIndex: number): Element`: Returns the element of the specified row
|
|
270
|
+
* `getRowYPos(physicalRowIndex: number): number?`: Returns the Y pos of the specified row
|
|
270
271
|
* `tableWidthChanged() {DGTable}`: *Undocumented yet*
|
|
271
272
|
* `tableHeightChanged() {DGTable}`: *Undocumented yet*
|
|
272
|
-
* `addRows({Object[]} data, {
|
|
273
|
-
* `removeRow({
|
|
274
|
-
* `removeRows({
|
|
275
|
-
* `refreshRow({
|
|
273
|
+
* `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
|
|
274
|
+
* `removeRow({number} physicalRowIndex, {boolean} render = true) {DGTable}`: Removes one row at the specified position
|
|
275
|
+
* `removeRows({number} physicalRowIndex, {number} count, {boolean} render = true) {DGTable}`: Removes rows at the specified position
|
|
276
|
+
* `refreshRow({number} physicalRowIndex) {DGTable}`: Refreshes the row specified
|
|
276
277
|
* *returns* Self
|
|
277
278
|
* `refreshAllVirtualRows() {DGTable}`: Refreshes all virtual rows
|
|
278
279
|
* *returns* Self
|
|
279
|
-
* `setRows(data: Object[], resort:
|
|
280
|
+
* `setRows(data: Object[], resort: boolean=false) {DGTable}`: Rests the table rows to the provided array of rows.
|
|
280
281
|
* **data**: New rows for the table
|
|
281
282
|
* **resort**: Should re-sort the table?
|
|
282
283
|
* *returns* Self, to allow for call chaining.
|
|
283
284
|
* `getUrlForElementContent({string} id) {string?}`: *Undocumented yet*
|
|
284
|
-
* `isWorkerSupported() {
|
|
285
|
+
* `isWorkerSupported() {boolean}`: *Undocumented yet*
|
|
285
286
|
* `createWebWorker({string} url) {Worker?}`: *Undocumented yet*
|
|
286
287
|
* `unbindWebWorker({Worker} worker) {DGTable}`: *Undocumented yet*
|
|
287
288
|
* `hideCellPreview() {DGTable}`: Hide any cell preview showing currently, or prevent showing a cell preview from within the `cellpreview` event.
|