├── .github
└── FUNDING.yml
├── Issue_template.txt
├── License.txt
├── Readme.md
├── bower.json
├── css
├── rowReorder.bootstrap.scss
├── rowReorder.bootstrap4.scss
├── rowReorder.bootstrap5.scss
├── rowReorder.bulma.scss
├── rowReorder.dataTables.scss
├── rowReorder.foundation.scss
├── rowReorder.jqueryui.scss
└── rowReorder.semanticui.scss
├── docs
├── api
│ ├── rowReorder.disable().xml
│ └── rowReorder.enable().xml
├── event
│ ├── pre-row-reorder.xml
│ ├── row-reorder-canceled.xml
│ ├── row-reorder-changed.xml
│ ├── row-reorder.xml
│ └── row-reordered.xml
└── option
│ ├── rowReorder.cancelable.xml
│ ├── rowReorder.dataSrc.xml
│ ├── rowReorder.editor.xml
│ ├── rowReorder.enable.xml
│ ├── rowReorder.formOptions.xml
│ ├── rowReorder.selector.xml
│ ├── rowReorder.snapX.xml
│ ├── rowReorder.update.xml
│ └── rowReorder.xml
├── examples
├── index.xml
├── initialisation
│ ├── ajax.xml
│ ├── cancelable.xml
│ ├── changed.xml
│ ├── defaults.xml
│ ├── events.xml
│ ├── index.xml
│ ├── responsive.xml
│ ├── restrictedOrdering.xml
│ ├── scroll.xml
│ ├── selector.xml
│ └── simple.xml
└── styling
│ ├── bootstrap.xml
│ ├── bootstrap4.xml
│ ├── bootstrap5.xml
│ ├── bulma.xml
│ ├── foundation.xml
│ ├── hamburger.xml
│ ├── index.xml
│ ├── jqueryui.xml
│ ├── reorderClass.xml
│ ├── semanticui.xml
│ └── snapX.xml
├── js
├── dataTables.rowReorder.js
├── rowReorder.bootstrap.js
├── rowReorder.bootstrap4.js
├── rowReorder.bootstrap5.js
├── rowReorder.bulma.js
├── rowReorder.dataTables.js
├── rowReorder.foundation.js
├── rowReorder.jqueryui.js
└── rowReorder.semanticui.js
├── make.sh
└── types
├── rowReorder.bootstrap.d.ts
├── rowReorder.bootstrap4.d.ts
├── rowReorder.bootstrap5.d.ts
├── rowReorder.bulma.d.ts
├── rowReorder.dataTables.d.ts
├── rowReorder.foundation.d.ts
├── rowReorder.jqueryui.d.ts
├── rowReorder.semanticui.d.ts
└── types.d.ts
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DataTables/RowReorder/66f5d5048643f54c986f66773e2474235ff3350e/.github/FUNDING.yml
--------------------------------------------------------------------------------
/Issue_template.txt:
--------------------------------------------------------------------------------
1 | Please post support requests and questions in the DataTables forums at https://datatables.net/forums. Support requests posted here will be closed. The intention of this request is to allow all questions to be located in a single, searchable, location.
2 |
3 | When you post your question in the DataTables forums, please ensure that you include a link to a page showing the issue so it can be debugged.
4 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | MIT license
2 |
3 | Copyright (c) 2015 SpryMedia Limited
4 | http://datatables.net
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # RowReorder
2 |
3 | RowReorder adds the ability for rows in a DataTable to be reordered through user interaction with the table (click and drag / touch and drag). Integration with Editor's multi-row editing feature is also available to update rows immediately.
4 |
5 |
6 | # Installation
7 |
8 | To use RowReorder the primary way to obtain the software is to use the [DataTables downloader](//datatables.net/download). You can also include the individual files from the [DataTables CDN](//cdn.datatables.net). See the [documentation](http://datatables.net/extensions/rowreorder/) for full details.
9 |
10 | ## NPM and Bower
11 |
12 | If you prefer to use a package manager such as NPM or Bower, distribution repositories are available with software built from this repository under the name `datatables.net-rowreorder`. Styling packages for Bootstrap, Foundation and other styling libraries are also available by adding a suffix to the package name.
13 |
14 | Please see the DataTables [NPM](//datatables.net/download/npm) and [Bower](//datatables.net/download/bower) installation pages for further information. The [DataTables installation manual](//datatables.net/manual/installation) also has details on how to use package managers with DataTables.
15 |
16 |
17 | # Basic usage
18 |
19 | RowReorder is initialised using the `rowReorder` option in the DataTables constructor - a simple boolean `true` will enable the feature. Further options can be specified using this option as an object - see the documentation for details.
20 |
21 | Example:
22 |
23 | ```js
24 | $(document).ready( function () {
25 | $('#myTable').DataTable( {
26 | rowReorder: true
27 | } );
28 | } );
29 | ```
30 |
31 |
32 | # Documentation / support
33 |
34 | * [Documentation](https://datatables.net/extensions/rowreorder/)
35 | * [DataTables support forums](http://datatables.net/forums)
36 |
37 |
38 | # GitHub
39 |
40 | If you fancy getting involved with the development of RowReorder and help make it better, please refer to its [GitHub repo](https://github.com/DataTables/RowReorder).
41 |
42 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "datatables-rowreorder",
3 | "main": [
4 | "js/dataTables.rowReorder.js",
5 | "css/rowReorder.dataTables.scss"
6 | ],
7 | "dependencies": {
8 | "jquery": ">=1.7.0",
9 | "datatables": ">=1.10.8"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/css/rowReorder.bootstrap.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid #337ab7 !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
--------------------------------------------------------------------------------
/css/rowReorder.bootstrap4.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid #0275d8 !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
--------------------------------------------------------------------------------
/css/rowReorder.bootstrap5.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid #0d6efd !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
7 | html[data-bs-theme="dark"] {
8 | div.dt-rowReorder-float-parent {
9 | outline-color: rgb(13, 110, 253);
10 | }
11 | }
--------------------------------------------------------------------------------
/css/rowReorder.bulma.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid #00d1b2 !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
--------------------------------------------------------------------------------
/css/rowReorder.dataTables.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid rgb(10, 89, 203) !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | div.dt-rowReorder-float-parent {
6 | table-layout: fixed;
7 | outline: $move-outline;
8 | z-index: 2001;
9 | position: absolute !important;
10 | overflow: hidden;
11 | border-radius: 3px;
12 |
13 | table.dt-rowReorder-float {
14 | opacity: 0.9;
15 | background-color: white;
16 | margin: 0 !important;
17 | }
18 | }
19 |
20 | div.dt-rowReorder-float-parent.drop-not-allowed {
21 | cursor: not-allowed;
22 | }
23 |
24 | tr.dt-rowReorder-moving {
25 | outline: $moved-outline;
26 | outline-offset: -2px;
27 | }
28 |
29 | body.dt-rowReorder-noOverflow {
30 | overflow-x: hidden;
31 | }
32 |
33 | table.dataTable td.reorder {
34 | text-align: center;
35 | cursor: move;
36 | }
37 |
38 | html.dark {
39 | div.dt-rowReorder-float-parent {
40 | outline-color: rgb(110, 168, 254);
41 |
42 | table.dt-rowReorder-float {
43 | background-color: var(--dt-html-background);
44 | }
45 | }
46 |
47 | tr.dt-rowReorder-moving {
48 | outline-color: #aaa;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/css/rowReorder.foundation.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid #337ab7 !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
--------------------------------------------------------------------------------
/css/rowReorder.jqueryui.scss:
--------------------------------------------------------------------------------
1 |
2 | @import 'rowReorder.dataTables.scss';
3 |
--------------------------------------------------------------------------------
/css/rowReorder.semanticui.scss:
--------------------------------------------------------------------------------
1 |
2 | $move-outline: 2px solid rgba(0,0,0,.05) !default;
3 | $moved-outline: 2px solid #888 !default;
4 |
5 | @import 'rowReorder.dataTables.scss';
6 |
--------------------------------------------------------------------------------
/docs/api/rowReorder.disable().xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.disable()
4 | Disable the user's ability to reorder rows.
5 | 1.2.0
6 |
7 |
8 | rowReorder.disable()
9 | Disable the end user's ability to click and drag to reorder rows.
10 | DataTables API instance
11 |
12 |
13 |
14 | It can sometimes be useful to enable and disable the end user's ability to reorder rows, for example while processing an update at the server-side. This method provides the ability to disable RowReorder. When disabled click and drag events will not be processed by RowReorder.
15 |
16 | Its companion method `-api rowReorder.enable()` can then be used to re-enable user interaction if required.
17 |
18 |
19 |
24 |
25 | -init rowReorder.enable
26 | -api rowReorder.enable()
27 | -api rowReorder.disable()
28 |
--------------------------------------------------------------------------------
/docs/api/rowReorder.enable().xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.enable()
4 | Enable / disable the user's ability to reorder rows.
5 | 1.2.0
6 |
7 |
8 | rowReorder.enable( [ enable ] )
9 | Enable, or optionally disable, the end user's ability to click and drag to reorder rows.
10 |
11 | Flag that can be used to indicate if row reordering should be enabled or disabled.
12 |
13 | DataTables API instance
14 |
15 |
16 |
17 | It can sometimes be useful to enable and disable the end user's ability to reorder rows, for example while processing an update at the server-side. This method provides the ability to both enable (its primary use!) and disable (through an optional boolean flag) RowReorder. When disabled click and drag events will not be processed by RowReorder.
18 |
19 |
20 |
25 |
26 | -init rowReorder.enable
27 | -api rowReorder.enable()
28 | -api rowReorder.disable()
29 |
--------------------------------------------------------------------------------
/docs/event/pre-row-reorder.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | pre-row-reorder
4 | A row reordered action has been initiated by the end user.
5 | 1.2.1
6 |
7 |
8 | function( e, node, position )
9 |
10 | jQuery event object
11 |
12 |
13 | An object that contains the following properties:
14 |
15 | * `node` (`-type node`) - The row being reordered.
16 | * `index` (`-type integer`) - The index of the row being reordered. Note this is the internal index of the row, not the display position.
17 |
18 | HTML table element
19 |
20 |
21 |
22 | When using RowReorder you may wish to know when a user starts a row reorder action. This event provides that ability.
23 |
24 | This event is triggered when a user grabs a row for reordering, before it is moved.
25 |
26 | Please note that, as with all DataTables emitted events, this event is triggered with the `dt` namespace. As such, to listen for this event, you must also use the `dt` namespace by simply appending `.dt` to your event name, or use the `dt-api on()` method to listen for the event which will automatically append this namespace.
27 |
28 |
29 |
42 |
43 |
--------------------------------------------------------------------------------
/docs/event/row-reorder-canceled.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | row-reorder-canceled
4 | Reordering canceled by the end user
5 | 1.3.3
6 |
7 |
8 | function( e, startRowIndex )
9 |
10 | jQuery event object
11 |
12 |
13 | The index of the row where the reordering initiated at.
14 |
15 | HTML table element
16 |
17 |
18 |
19 | If the cancelable option enabled this event is fired when the ESC key is pressed or the user dropped the element outside of the table.
20 |
21 | Please note that, as with all DataTables emitted events, this event is triggered with the `dt` namespace. As such, to listen for this event, you must also use the `dt` namespace by simply appending `.dt` to your event name, or use the `dt-api on()` method to listen for the event which will automatically append this namespace.
22 |
23 |
24 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/docs/event/row-reorder-changed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | row-reorder-changed
4 | Row moved into new position by the end user
5 | 1.3.3
6 |
7 |
8 | function( e, params )
9 |
10 | jQuery event object
11 |
12 |
13 | This parameter provides the following information:
14 |
15 | * `-type string` `insertPlacement` - Insert placement, either `before` or `after`
16 | * `-type integer` `insertPoint` - Insert point starting from `0`
17 | * `-type object` `row` - DOM node of the moved row
18 |
19 | HTML table element
20 |
21 |
22 |
23 | This event is fired when the user moves a given row into a new position.
24 |
25 | Please note that, as with all DataTables emitted events, this event is triggered with the `dt` namespace. As such, to listen for this event, you must also use the `dt` namespace by simply appending `.dt` to your event name, or use the `dt-api on()` method to listen for the event which will automatically append this namespace.
26 |
27 |
28 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/docs/event/row-reorder.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | row-reorder
4 | Rows have been reordered by the end user
5 | 1.0.0
6 |
7 |
8 | function( e, details, edit )
9 |
10 | jQuery event object
11 |
12 |
13 | An array of change objects for the row's how have had values effected. Each object contain the following properties:
14 |
15 | * `-type *` `newData` - The new data value for the row (data point defined by `rr-init rowReorder.dataSrc`)
16 | * `-type node` `node` - The `-tag tr` element
17 | * `-type integer` `newPosition` - New index in the DOM
18 | * `-type *` `oldData` - The old data value for the row
19 | * `-type integer` `oldPosition` - Old index in the DOM
20 |
21 |
22 | This parameter provides the information required for [Editor](//editor.datatables.net) to perform a multi-row edit:
23 |
24 | * `-type string` `dataSrc` - Data point - typically the field to be edited (defined by `rr-init rowReorder.dataSrc`)
25 | * `-type array` `nodes` - The rows to be edited
26 | * `-type object` `values` - The new values in a format suitable for `e-api multiSet()`.
27 | * `-type DataTable.Api` `triggerRow` (Since v1.1.0) - Row API instance for the row that was used to start the reorder (i.e. the result from `dt-api row()`).
28 | * `-type object` `originalEvent` (Since v1.2.6) - The original event (mouseup) that triggered the reorder.
29 |
30 | HTML table element
31 |
32 |
33 |
34 | When using RowReorder you will likely wish to know when a table has been reordered by an end user so you can update a data store to reflect these changes. This event provides that ability.
35 |
36 | The data that has been changed by RowReorder is given in two different forms in the parameters for the event handler callback - one with detailed information about the individual rows, and one with data in a format suitable for [Editor's](//editor.datatables.net) multi-row editing feature.
37 |
38 | This event is triggered when a row is dropped, but prior to the new data being written to the database.
39 |
40 | As of RowReorder 1.4.1 this event is cancellable by returning `false` from the event handler function. If there are multiple event handlers, the last non-`undefined` return value will be used as the return value after all event handlers have been executed in order.
41 |
42 | Please note that, as with all DataTables emitted events, this event is triggered with the `dt` namespace. As such, to listen for this event, you must also use the `dt` namespace by simply appending `.dt` to your event name, or use the `dt-api on()` method to listen for the event which will automatically append this namespace.
43 |
44 |
45 |
56 |
57 |
67 |
--------------------------------------------------------------------------------
/docs/event/row-reordered.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | row-reordered
4 | After rows have been reordered by the end user
5 | 1.0.0
6 |
7 |
8 | function( e, details, edit )
9 |
10 | jQuery event object
11 |
12 |
13 | An array of change objects for the row's how have had values effected. Each object contain the following properties:
14 |
15 | * `-type *` `newData` - The new data value for the row (data point defined by `rr-init rowReorder.dataSrc`)
16 | * `-type node` `node` - The `-tag tr` element
17 | * `-type integer` `newPosition` - New index in the DOM
18 | * `-type *` `oldData` - The old data value for the row
19 | * `-type integer` `oldPosition` - Old index in the DOM
20 |
21 |
22 | This parameter provides the information required for [Editor](//editor.datatables.net) to perform a multi-row edit:
23 |
24 | * `-type string` `dataSrc` - Data point - typically the field to be edited (defined by `rr-init rowReorder.dataSrc`)
25 | * `-type array` `nodes` - The rows to be edited
26 | * `-type object` `values` - The new values in a format suitable for `e-api multiSet()`.
27 | * `-type DataTable.Api` `triggerRow` (Since v1.1.0) - Row API instance for the row that was used to start the reorder (i.e. the result from `dt-api row()`).
28 |
29 | HTML table element
30 |
31 |
32 |
33 | The event data is identical to the `rr-event row-reorder` event. In comparison to the `rr-event row-reorder` event, the event will be triggered after the row is dropped and after the data is updated.
34 | This event is only triggered if the `rr-init rowReorder.update` option has been enabled (which it is by default).
35 |
36 | The data that has been changed by RowReorder is given in two different forms in the parameters for the event handler callback - one with detailed information about the individual rows, and one with data in a format suitable for [Editor's](//editor.datatables.net) multi-row editing feature.
37 |
38 | Please note that, as with all DataTables emitted events, this event is triggered with the `dt` namespace. As such, to listen for this event, you must also use the `dt` namespace by simply appending `.dt` to your event name, or use the `dt-api on()` method to listen for the event which will automatically append this namespace.
39 |
40 |
41 |
52 |
53 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.cancelable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.cancelable
4 | Enable / disable the canceling of the drag and drop interaction
5 |
6 |
7 |
8 | * `true` - Canceling is enabled either by pressing the ESC key or dropping the element outside of the table.
9 | * `false` - Canceling is disabled.
10 |
11 |
12 |
13 |
14 | Canceling is not enabled.
15 |
16 |
17 |
18 |
19 |
20 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.dataSrc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.dataSrc
4 | Configure the data point that will be used for the reordering data
5 |
6 |
7 |
8 | Array index for when DataTables stores row data in arrays. Use this option if you **do not** set `dt-init columns.data` for your column.
9 |
10 |
11 |
12 |
13 |
14 | Object property for when DataTables stores row data in objects. Use this option if you **do** set `dt-init columns.data` for your column. Like `dt-init columns.data` this option can be used with nested JSON data using dotted Javascript notation - this can be particularly useful for working with tables where the data is sourced from joined SQL tables.
15 |
16 |
17 |
18 |
19 | Array index 0.
20 |
21 |
22 |
23 | When rows are reordered, RowReorder will automatically adjust the data in the DataTable to reflect the change made by the reordering. This option tells RowReorder what data property in the data source object / array for each row (see `dt-api row().data()`) should be read and set.
24 |
25 | Typically this option will be used to point to a column with a sequence number that defines an order. However, this need not be the case - any property in the data source object can be used, even one that is not used in a DataTables column.
26 |
27 |
28 |
35 |
36 |
43 |
44 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.editor.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.editor
4 | Attach an Editor instance for database updating
5 | 1.0.0
6 |
7 |
8 |
9 | The Editor instance to use for editing of the table
10 |
11 |
12 |
13 |
14 | No Editor instance is automatically attached.
15 |
16 |
17 |
18 | When completing a row reordering action you will typically wish to update the data source to reflect the changes made by the end user. This can be done with RowReorder's integration with [Editor](//editor.datatables.net).
19 |
20 | This option can specify an Editor instance that should be used to submit the changes to the server. Upon drag completion the changes will be immediately submitted to the server and the table redrawn with the updated data retrieved from the server.
21 |
22 |
23 |
31 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.enable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.enable
4 | Enable / disable RowReorder's user interaction
5 |
6 |
7 |
8 | Boolean flag to indicate if RowReorder should be enabled or not.
9 |
10 |
11 |
12 |
13 | RowReorder is enabled by default when the `rowReorder` property is included in the DataTables initialisation.
14 |
15 |
16 |
17 | This option can be used to disable RowReorder's end user interaction when the DataTable is first created. It can then later be enabled using the `-api rowReorder.enable()` API method.
18 |
19 |
20 |
27 |
28 | -init rowReorder.enable
29 | -api rowReorder.enable()
30 | -api rowReorder.disable()
31 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.formOptions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.formOptions
4 | Set the options for the Editor form when submitting data
5 | 1.1.3
6 |
7 |
8 |
9 | A form options object for Editor. Please refer to the `e-type form-options` documentation for full information on the options available for this parameter.
10 |
11 |
12 |
13 |
14 | An empty object is used by default. RowReorder augments that with the option `submit: 'changed'` which can be overridden if required.
15 |
16 |
17 |
18 | When Editor is used with RowReorder (`-init rowReorder.editor`) it will automatically submit only the changed values when rows are reordered in the table. Editor also has the option to submit the full information for the row through the `submit` parameter of the `e-type form-options` object. This parameter provides the ability to configure the `e-type form-options` used by RowReorder.
19 |
20 | Only the `submit` parameter is likely to be useful for the `e-type form-options` object when used in RowReorder, although it is possible to set the other parameters as well.
21 |
22 |
23 |
34 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.selector
4 | Define the selector used to pick the elements that will start a drag
5 |
6 |
7 |
8 | [jQuery selector](https://api.jquery.com/category/selectors/) to select which element will be used as the drag start handle.
9 |
10 |
11 |
12 |
13 | First visible cell in the table
14 |
15 |
16 |
17 | In order to be able to start a row drag and drop reorder, the user needs to be able to click and drag an element in the row. This option defines what element in the table row performs that option.
18 |
19 | The value of this option can take any [jQuery selector](https://api.jquery.com/category/selectors/), providing the option to provide potentially complex selection options, but typically you will wish to select either a specific cell (the default value is to select the first visible cell in the table), the whole row or a specific _button_ in the table that is styles to appear as a drag start handle to the end user.
20 |
21 |
22 |
29 |
30 |
37 |
38 |
45 |
46 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.snapX.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.snapX
4 | Horizontal position control of the row being dragged
5 |
6 |
7 |
8 | * `true` - the dragged row follows the mouse only vertically. It is locked to the left of the table horizontally.
9 | * `false` - the dragged row follows the mouse both horizontally and vertically
10 |
11 |
12 |
13 |
14 |
15 | Offset from the left of the table that the horizontal position is locked to. This can be a positive number (offset to the right) or a negative number (offset to the left).
16 |
17 |
18 |
19 |
20 | Dragged row follows the mouse both horizontally and vertically
21 |
22 |
23 |
24 | When RowReorder starts a drag, it clones the original target row and the clone is moved with the mouse, giving the end user visual feedback about the drag action.
25 |
26 | By default the cloned row will be moved with the mouse both horizontally and vertically. However, only the virtual position is particularly important and it can be nice to lock the row to the host table vertically. This option provides that ability.
27 |
28 |
29 |
36 |
37 |
44 |
45 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.update.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder.update
4 | Control automatic of data when a row is dropped
5 |
6 |
7 |
8 | * `true` - DataTables data is automatically updated as a result of the row reordering and the table redrawn.
9 | * `false` - No data update or draw is performed.
10 |
11 |
12 |
13 |
14 | Data is updated and table redrawn
15 |
16 |
17 |
18 | At the end of a row reordering action you will typically wish to take some action to reflect the change from the reordering action. By default RowReorder will read the data from the reordered rows and update that same data based on the row's new position in the table. It will then redraw the table to account for any changes in ordering.
19 |
20 | This action is not always desirable, particularly if you are using server-side processing or wish to have an external process update the data. In such circumstances this option can be used to disable the automatic data update and draw. The `rr-event row-reorder` event can then be used to determine what actions should be taken based on the reordered rows.
21 |
22 |
23 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/docs/option/rowReorder.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | rowReorder
4 | Enable and configure the RowReorder extension for DataTables
5 |
6 |
7 |
8 | As a boolean value this property will enable RowReorder on the DataTable that is being created. `true` will enable RowReorder, while `false` will not.
9 |
10 | This is a short-cut option to enable RowReorder with the default configuration options. Customisations can be made by giving this parameter as an object, see below.
11 |
12 |
13 |
14 |
15 |
16 | If given as an object, RowReorder will be enabled on the target DataTable, with default values (`$.fn.dataTable.RowReorder.defaults`) extended, and potentially overwritten, by the options provided in this object. This is how RowReorder can be configured on an individual table basis, or through the defaults.
17 |
18 |
19 |
20 |
21 | RowReorder will not be initialised by default
22 |
23 |
24 |
25 | This option provides the ability to enable and configure RowReorder for DataTables. In its simplest form as the boolean `true` it will enable RowReorder with the default configuration options (as defined by `$.fn.dataTable.RowReorder.defaults`). It can also be used as an object to provide custom configuration options as described below.
26 |
27 | Please note that as with all other configuration options for RowReorder, this option is an extension to the [default set of DataTables options](/reference/option). This property should be set in the DataTables initialisation object.
28 |
29 |
30 |
35 |
36 |
43 |
44 |
--------------------------------------------------------------------------------
/examples/index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | RowReorder examples
5 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/initialisation/ajax.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
25 |
26 |
27 |
28 |
47 |
48 |
49 | Ajax data source with objects
50 |
51 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/examples/initialisation/cancelable.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
23 |
24 |
25 |
26 |
44 |
45 |
46 | Cancelable
47 |
48 |
53 |
54 |
55 | .
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/examples/initialisation/changed.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
26 |
27 |
28 |
29 |
50 |
51 |
52 | Changed event
53 |
54 |
58 |
59 |
60 | Reordering has not started yet.
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/examples/initialisation/defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
18 |
19 |
20 |
21 |
33 |
34 |
35 | Defaults
36 |
37 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/examples/initialisation/events.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ';
14 |
15 | for (var i = 0, ien = diff.length; i < ien; i++) {
16 | var rowData = table.row(diff[i].node).data();
17 |
18 | result +=
19 | rowData[1] +
20 | ' updated to be in position ' +
21 | diff[i].newData +
22 | ' (was ' +
23 | diff[i].oldData +
24 | ')
';
25 | }
26 |
27 | $('#result').html('Event result:
' + result);
28 | });
29 |
30 | ]]>
31 |
32 |
33 |
34 | ';
42 |
43 | for (var i = 0, ien = diff.length; i < ien; i++) {
44 | let rowData = table.row(diff[i].node).data();
45 |
46 | result +=
47 | `${rowData[1]} updated to be in position ${diff[i].newData} ` +
48 | `(was ${diff[i].oldData})
`;
49 | }
50 |
51 | document.querySelector('#result').innerHTML = 'Event result:
' + result;
52 | });
53 |
54 | ]]>
55 |
56 |
57 | Reorder event
58 |
59 |
68 |
69 |
70 | Event result:
71 |
72 |
73 |
74 |
75 |
--------------------------------------------------------------------------------
/examples/initialisation/index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Initialisation
5 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/initialisation/responsive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
16 |
17 |
18 |
19 |
29 |
30 |
31 | Mobile support (Responsive integration)
32 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/examples/initialisation/restrictedOrdering.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
20 |
31 |
32 |
33 | Restricted column ordering (sorting)
34 |
35 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/examples/initialisation/scroll.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
15 |
16 |
17 |
18 |
27 |
28 |
29 | DataTables Scrolling
30 |
31 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/examples/initialisation/selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
16 |
17 |
18 |
19 |
29 |
30 |
31 | Full row selection
32 |
33 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/examples/initialisation/simple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Basic initialisation
26 |
27 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/examples/styling/bootstrap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Bootstrap styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/bootstrap4.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Bootstrap 4 styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/bootstrap5.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Bootstrap 5 styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/bulma.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Bulma styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/foundation.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Foundation styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/hamburger.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | table.dataTable td.reorder {
6 | color: #999;
7 | }
8 |
9 |
10 |
30 |
31 |
32 |
33 | '≡',
39 | targets: 0
40 | },
41 | { orderable: false, targets: '_all' }
42 | ],
43 | order: [[1, 'asc']],
44 | rowReorder: {
45 | dataSrc: 1
46 | }
47 | });
48 |
49 |
50 | ]]>
51 |
52 |
53 | Hamburger icon for reordering
54 |
55 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/examples/styling/index.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Styling
5 |
6 |
7 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/examples/styling/jqueryui.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | jQuery UI styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/reorderClass.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
17 |
18 |
19 |
20 |
31 |
32 |
33 | Selector cell styling
34 |
35 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/examples/styling/semanticui.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
13 |
14 |
15 |
16 |
23 |
24 |
25 | Fomantic-UI (formally Semantic-UI) styling
26 |
27 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/styling/snapX.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
15 |
16 |
17 |
18 |
27 |
28 |
29 | Horizontal snap
30 |
31 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/js/dataTables.rowReorder.js:
--------------------------------------------------------------------------------
1 | /*! RowReorder 1.5.0
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
5 | /**
6 | * @summary RowReorder
7 | * @description Row reordering extension for DataTables
8 | * @version 1.5.0
9 | * @author SpryMedia Ltd
10 | * @contact datatables.net
11 | *
12 | * This source file is free software, available under the following license:
13 | * MIT license - http://datatables.net/license/mit
14 | *
15 | * This source file is distributed in the hope that it will be useful, but
16 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 | * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
18 | *
19 | * For details please refer to: http://www.datatables.net
20 | */
21 |
22 | /**
23 | * RowReorder provides the ability in DataTables to click and drag rows to
24 | * reorder them. When a row is dropped the data for the rows effected will be
25 | * updated to reflect the change. Normally this data point should also be the
26 | * column being sorted upon in the DataTable but this does not need to be the
27 | * case. RowReorder implements a "data swap" method - so the rows being
28 | * reordered take the value of the data point from the row that used to occupy
29 | * the row's new position.
30 | *
31 | * Initialisation is done by either:
32 | *
33 | * * `rowReorder` parameter in the DataTable initialisation object
34 | * * `new DataTable.RowReorder( table, opts )` after DataTables
35 | * initialisation.
36 | *
37 | * @class
38 | * @param {object} settings DataTables settings object for the host table
39 | * @param {object} [opts] Configuration options
40 | * @requires jQuery 1.7+
41 | * @requires DataTables 1.11
42 | */
43 | var RowReorder = function (dt, opts) {
44 | // Sanity check that we are using DataTables 1.10 or newer
45 | if (!DataTable.versionCheck || !DataTable.versionCheck('1.11')) {
46 | throw 'DataTables RowReorder requires DataTables 1.11 or newer';
47 | }
48 |
49 | // User and defaults configuration object
50 | this.c = $.extend(true, {}, DataTable.defaults.rowReorder, RowReorder.defaults, opts);
51 |
52 | // Internal settings
53 | this.s = {
54 | /** @type {integer} Scroll body top cache */
55 | bodyTop: null,
56 |
57 | /** @type {DataTable.Api} DataTables' API instance */
58 | dt: new DataTable.Api(dt),
59 |
60 | /** @type {function} Data fetch function */
61 | getDataFn: DataTable.util.get(this.c.dataSrc),
62 |
63 | /** @type {array} Pixel positions for row insertion calculation */
64 | middles: null,
65 |
66 | /** @type {Object} Cached dimension information for use in the mouse move event handler */
67 | scroll: {},
68 |
69 | /** @type {integer} Interval object used for smooth scrolling */
70 | scrollInterval: null,
71 |
72 | /** @type {function} Data set function */
73 | setDataFn: DataTable.util.set(this.c.dataSrc),
74 |
75 | /** @type {Object} Mouse down information */
76 | start: {
77 | top: 0,
78 | left: 0,
79 | offsetTop: 0,
80 | offsetLeft: 0,
81 | nodes: [],
82 | rowIndex: 0
83 | },
84 |
85 | /** @type {integer} Window height cached value */
86 | windowHeight: 0,
87 |
88 | /** @type {integer} Document outer height cached value */
89 | documentOuterHeight: 0,
90 |
91 | /** @type {integer} DOM clone outer height cached value */
92 | domCloneOuterHeight: 0,
93 |
94 | /** @type {integer} Flag used for signing if the drop is enabled or not */
95 | dropAllowed: true
96 | };
97 |
98 | // DOM items
99 | this.dom = {
100 | /** @type {jQuery} Cloned row being moved around */
101 | clone: null,
102 | cloneParent: null,
103 |
104 | /** @type {jQuery} DataTables scrolling container */
105 | dtScroll: $('div.dataTables_scrollBody, div.dt-scroll-body', this.s.dt.table().container())
106 | };
107 |
108 | // Check if row reorder has already been initialised on this table
109 | var settings = this.s.dt.settings()[0];
110 | var existing = settings.rowreorder;
111 |
112 | if (existing) {
113 | return existing;
114 | }
115 |
116 | if (!this.dom.dtScroll.length) {
117 | this.dom.dtScroll = $(this.s.dt.table().container(), 'tbody');
118 | }
119 |
120 | settings.rowreorder = this;
121 | this._constructor();
122 | };
123 |
124 | $.extend(RowReorder.prototype, {
125 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
126 | * Constructor
127 | */
128 |
129 | /**
130 | * Initialise the RowReorder instance
131 | *
132 | * @private
133 | */
134 | _constructor: function () {
135 | var that = this;
136 | var dt = this.s.dt;
137 | var table = $(dt.table().node());
138 |
139 | // Need to be able to calculate the row positions relative to the table
140 | if (table.css('position') === 'static') {
141 | table.css('position', 'relative');
142 | }
143 |
144 | // listen for mouse down on the target column - we have to implement
145 | // this rather than using HTML5 drag and drop as drag and drop doesn't
146 | // appear to work on table rows at this time. Also mobile browsers are
147 | // not supported.
148 | // Use `table().container()` rather than just the table node for IE8 -
149 | // otherwise it only works once...
150 | $(dt.table().container()).on(
151 | 'mousedown.rowReorder touchstart.rowReorder',
152 | this.c.selector,
153 | function (e) {
154 | if (!that.c.enable) {
155 | return;
156 | }
157 |
158 | // Ignore excluded children of the selector
159 | if ($(e.target).is(that.c.excludedChildren)) {
160 | return true;
161 | }
162 |
163 | var tr = $(this).closest('tr');
164 | var row = dt.row(tr);
165 |
166 | // Double check that it is a DataTable row
167 | if (row.any()) {
168 | that._emitEvent('pre-row-reorder', {
169 | node: row.node(),
170 | index: row.index()
171 | });
172 |
173 | that._mouseDown(e, tr);
174 | return false;
175 | }
176 | }
177 | );
178 |
179 | dt.on('destroy.rowReorder', function () {
180 | $(dt.table().container()).off('.rowReorder');
181 | dt.off('.rowReorder');
182 | });
183 |
184 | this._keyup = this._keyup.bind(this);
185 | },
186 |
187 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
188 | * Private methods
189 | */
190 |
191 | /**
192 | * Cache the measurements that RowReorder needs in the mouse move handler
193 | * to attempt to speed things up, rather than reading from the DOM.
194 | *
195 | * @private
196 | */
197 | _cachePositions: function () {
198 | var dt = this.s.dt;
199 |
200 | // Frustratingly, if we add `position:relative` to the tbody, the
201 | // position is still relatively to the parent. So we need to adjust
202 | // for that
203 | var headerHeight = $(dt.table().node()).find('thead').outerHeight();
204 |
205 | // Need to pass the nodes through jQuery to get them in document order,
206 | // not what DataTables thinks it is, since we have been altering the
207 | // order
208 | var nodes = $.unique(dt.rows({ page: 'current' }).nodes().toArray());
209 | var middles = $.map(nodes, function (node, i) {
210 | var top = $(node).position().top - headerHeight;
211 |
212 | return (top + top + $(node).outerHeight()) / 2;
213 | });
214 |
215 | this.s.middles = middles;
216 | this.s.bodyTop = $(dt.table().body()).offset().top;
217 | this.s.windowHeight = $(window).height();
218 | this.s.documentOuterHeight = $(document).outerHeight();
219 | this.s.bodyArea = this._calcBodyArea();
220 | },
221 |
222 | /**
223 | * Clone a row so it can be floated around the screen
224 | *
225 | * @param {jQuery} target Node to be cloned
226 | * @private
227 | */
228 | _clone: function (target) {
229 | var dt = this.s.dt;
230 | var clone = $(dt.table().node().cloneNode(false))
231 | .addClass('dt-rowReorder-float')
232 | .append('
')
233 | .append(target.clone(false));
234 |
235 | // Match the table and column widths - read all sizes before setting
236 | // to reduce reflows
237 | var tableWidth = target.outerWidth();
238 | var tableHeight = target.outerHeight();
239 | var scrollBody = $($(this.s.dt.table().node()).parent());
240 | var scrollWidth = scrollBody.width();
241 | var scrollLeft = scrollBody.scrollLeft();
242 | var sizes = target.children().map(function () {
243 | return $(this).width();
244 | });
245 |
246 | clone
247 | .width(tableWidth)
248 | .height(tableHeight)
249 | .find('tr')
250 | .children()
251 | .each(function (i) {
252 | this.style.width = sizes[i] + 'px';
253 | });
254 |
255 | var cloneParent = $('')
256 | .addClass('dt-rowReorder-float-parent')
257 | .width(scrollWidth)
258 | .append(clone)
259 | .appendTo('body')
260 | .scrollLeft(scrollLeft);
261 |
262 | // Insert into the document to have it floating around
263 |
264 | this.dom.clone = clone;
265 | this.dom.cloneParent = cloneParent;
266 | this.s.domCloneOuterHeight = clone.outerHeight();
267 | },
268 |
269 | /**
270 | * Update the cloned item's position in the document
271 | *
272 | * @param {object} e Event giving the mouse's position
273 | * @private
274 | */
275 | _clonePosition: function (e) {
276 | var start = this.s.start;
277 | var topDiff = this._eventToPage(e, 'Y') - start.top;
278 | var leftDiff = this._eventToPage(e, 'X') - start.left;
279 | var snap = this.c.snapX;
280 | var left;
281 | var top = topDiff + start.offsetTop;
282 |
283 | if (snap === true) {
284 | left = start.offsetLeft;
285 | }
286 | else if (typeof snap === 'number') {
287 | left = start.offsetLeft + snap;
288 | }
289 | else {
290 | left = leftDiff + start.offsetLeft + this.dom.cloneParent.scrollLeft();
291 | }
292 |
293 | if (top < 0) {
294 | top = 0;
295 | }
296 | else if (top + this.s.domCloneOuterHeight > this.s.documentOuterHeight) {
297 | top = this.s.documentOuterHeight - this.s.domCloneOuterHeight;
298 | }
299 |
300 | this.dom.cloneParent.css({
301 | top: top,
302 | left: left
303 | });
304 | },
305 |
306 | /**
307 | * Emit an event on the DataTable for listeners
308 | *
309 | * @param {string} name Event name
310 | * @param {array} args Event arguments
311 | * @private
312 | */
313 | _emitEvent: function ( name, args )
314 | {
315 | var ret;
316 |
317 | this.s.dt.iterator( 'table', function ( ctx, i ) {
318 | var innerRet = $(ctx.nTable).triggerHandler( name+'.dt', args );
319 |
320 | if (innerRet !== undefined) {
321 | ret = innerRet;
322 | }
323 | } );
324 |
325 | return ret;
326 | },
327 |
328 | /**
329 | * Get pageX/Y position from an event, regardless of if it is a mouse or
330 | * touch event.
331 | *
332 | * @param {object} e Event
333 | * @param {string} pos X or Y (must be a capital)
334 | * @private
335 | */
336 | _eventToPage: function (e, pos) {
337 | if (e.type.indexOf('touch') !== -1) {
338 | return e.originalEvent.touches[0]['page' + pos];
339 | }
340 |
341 | return e['page' + pos];
342 | },
343 |
344 | /**
345 | * Mouse down event handler. Read initial positions and add event handlers
346 | * for the move.
347 | *
348 | * @param {object} e Mouse event
349 | * @param {jQuery} target TR element that is to be moved
350 | * @private
351 | */
352 | _mouseDown: function (e, target) {
353 | var that = this;
354 | var dt = this.s.dt;
355 | var start = this.s.start;
356 | var cancelable = this.c.cancelable;
357 |
358 | var offset = target.offset();
359 | start.top = this._eventToPage(e, 'Y');
360 | start.left = this._eventToPage(e, 'X');
361 | start.offsetTop = offset.top;
362 | start.offsetLeft = offset.left;
363 | start.nodes = $.unique(dt.rows({ page: 'current' }).nodes().toArray());
364 |
365 | this._cachePositions();
366 | this._clone(target);
367 | this._clonePosition(e);
368 |
369 | var bodyY = this._eventToPage(e, 'Y') - this.s.bodyTop;
370 | start.rowIndex = this._calcRowIndexByPos(bodyY);
371 |
372 | this.dom.target = target;
373 | target.addClass('dt-rowReorder-moving');
374 |
375 | $(document)
376 | .on('mouseup.rowReorder touchend.rowReorder', function (e) {
377 | that._mouseUp(e);
378 | })
379 | .on('mousemove.rowReorder touchmove.rowReorder', function (e) {
380 | that._mouseMove(e);
381 | });
382 |
383 | // Check if window is x-scrolling - if not, disable it for the duration
384 | // of the drag
385 | if ($(window).width() === $(document).width()) {
386 | $(document.body).addClass('dt-rowReorder-noOverflow');
387 | }
388 |
389 | // Cache scrolling information so mouse move doesn't need to read.
390 | // This assumes that the window and DT scroller will not change size
391 | // during an row drag, which I think is a fair assumption
392 | var scrollWrapper = this.dom.dtScroll;
393 | this.s.scroll = {
394 | windowHeight: $(window).height(),
395 | windowWidth: $(window).width(),
396 | dtTop: scrollWrapper.length ? scrollWrapper.offset().top : null,
397 | dtLeft: scrollWrapper.length ? scrollWrapper.offset().left : null,
398 | dtHeight: scrollWrapper.length ? scrollWrapper.outerHeight() : null,
399 | dtWidth: scrollWrapper.length ? scrollWrapper.outerWidth() : null
400 | };
401 |
402 | // Add keyup handler if dragging is cancelable
403 | if (cancelable) {
404 | $(document).on('keyup', this._keyup);
405 | }
406 | },
407 |
408 | /**
409 | * Mouse move event handler - move the cloned row and shuffle the table's
410 | * rows if required.
411 | *
412 | * @param {object} e Mouse event
413 | * @private
414 | */
415 | _mouseMove: function (e) {
416 | this._clonePosition(e);
417 |
418 | var start = this.s.start;
419 | var cancelable = this.c.cancelable;
420 |
421 | if (cancelable) {
422 | var bodyArea = this.s.bodyArea;
423 | var cloneArea = this._calcCloneParentArea();
424 |
425 | this.s.dropAllowed = this._rectanglesIntersect(bodyArea, cloneArea);
426 | $(this.dom.cloneParent).toggleClass('drop-not-allowed', !this.s.dropAllowed);
427 | }
428 |
429 | // Transform the mouse position into a position in the table's body
430 | var bodyY = this._eventToPage(e, 'Y') - this.s.bodyTop;
431 | var middles = this.s.middles;
432 | var insertPoint = null;
433 |
434 | // Determine where the row should be inserted based on the mouse
435 | // position
436 | for (var i = 0, ien = middles.length; i < ien; i++) {
437 | if (bodyY < middles[i]) {
438 | insertPoint = i;
439 | break;
440 | }
441 | }
442 |
443 | if (insertPoint === null) {
444 | insertPoint = middles.length;
445 | }
446 |
447 | if (cancelable) {
448 | if (!this.s.dropAllowed) {
449 | // Move the row back to its original position becasuse the drop is not allowed
450 | insertPoint =
451 | start.rowIndex > this.s.lastInsert ? start.rowIndex + 1 : start.rowIndex;
452 | }
453 |
454 | this.dom.target.toggleClass('dt-rowReorder-moving', this.s.dropAllowed);
455 | }
456 |
457 | this._moveTargetIntoPosition(insertPoint);
458 |
459 | this._shiftScroll(e);
460 | },
461 |
462 | /**
463 | * Mouse up event handler - release the event handlers and perform the
464 | * table updates
465 | *
466 | * @param {object} e Mouse event
467 | * @private
468 | */
469 | _mouseUp: function (e) {
470 | var that = this;
471 | var dt = this.s.dt;
472 | var i, ien;
473 | var dataSrc = this.c.dataSrc;
474 | var dropAllowed = this.s.dropAllowed;
475 |
476 | if (!dropAllowed) {
477 | that._cancel();
478 | return;
479 | }
480 |
481 | // Calculate the difference
482 | var startNodes = this.s.start.nodes;
483 | var endNodes = $.unique(dt.rows({ page: 'current' }).nodes().toArray());
484 | var idDiff = {};
485 | var fullDiff = [];
486 | var diffNodes = [];
487 | var getDataFn = this.s.getDataFn;
488 | var setDataFn = this.s.setDataFn;
489 |
490 | for (i = 0, ien = startNodes.length; i < ien; i++) {
491 | if (startNodes[i] !== endNodes[i]) {
492 | var id = dt.row(endNodes[i]).id();
493 | var endRowData = dt.row(endNodes[i]).data();
494 | var startRowData = dt.row(startNodes[i]).data();
495 |
496 | if (id) {
497 | idDiff[id] = getDataFn(startRowData);
498 | }
499 |
500 | fullDiff.push({
501 | node: endNodes[i],
502 | oldData: getDataFn(endRowData),
503 | newData: getDataFn(startRowData),
504 | newPosition: i,
505 | oldPosition: $.inArray(endNodes[i], startNodes)
506 | });
507 |
508 | diffNodes.push(endNodes[i]);
509 | }
510 | }
511 |
512 | // Create event args
513 | var eventArgs = [
514 | fullDiff,
515 | {
516 | dataSrc: dataSrc,
517 | nodes: diffNodes,
518 | values: idDiff,
519 | triggerRow: dt.row(this.dom.target),
520 | originalEvent: e
521 | }
522 | ];
523 |
524 | // Emit event
525 | var eventResult = this._emitEvent( 'row-reorder', eventArgs );
526 |
527 | if (eventResult === false) {
528 | that._cancel();
529 | return;
530 | }
531 |
532 | // Remove cloned elements, handlers, etc
533 | this._cleanupDragging();
534 |
535 | var update = function () {
536 | if (that.c.update) {
537 | for (i = 0, ien = fullDiff.length; i < ien; i++) {
538 | var row = dt.row(fullDiff[i].node);
539 | var rowData = row.data();
540 |
541 | setDataFn(rowData, fullDiff[i].newData);
542 |
543 | // Invalidate the cell that has the same data source as the dataSrc
544 | dt.columns().every(function () {
545 | if (this.dataSrc() === dataSrc) {
546 | dt.cell(fullDiff[i].node, this.index()).invalidate('data');
547 | }
548 | });
549 | }
550 |
551 | // Trigger row reordered event
552 | that._emitEvent('row-reordered', eventArgs);
553 |
554 | dt.draw(false);
555 | }
556 | };
557 |
558 | // Editor interface
559 | if (this.c.editor) {
560 | // Disable user interaction while Editor is submitting
561 | this.c.enable = false;
562 |
563 | this.c.editor
564 | .edit(diffNodes, false, $.extend({ submit: 'changed' }, this.c.formOptions))
565 | .multiSet(dataSrc, idDiff)
566 | .one('preSubmitCancelled.rowReorder', function () {
567 | that.c.enable = true;
568 | that.c.editor.off('.rowReorder');
569 | dt.draw(false);
570 | })
571 | .one('submitUnsuccessful.rowReorder', function () {
572 | dt.draw(false);
573 | })
574 | .one('submitSuccess.rowReorder', function () {
575 | update();
576 | })
577 | .one('submitComplete', function () {
578 | that.c.enable = true;
579 | that.c.editor.off('.rowReorder');
580 | })
581 | .submit();
582 | }
583 | else {
584 | update();
585 | }
586 | },
587 |
588 | /**
589 | * Moves the current target into the given position within the table
590 | * and caches the new positions
591 | *
592 | * @param {integer} insertPoint Position
593 | * @private
594 | */
595 | _moveTargetIntoPosition: function (insertPoint) {
596 | var dt = this.s.dt;
597 |
598 | // Perform the DOM shuffle if it has changed from last time
599 | if (this.s.lastInsert === null || this.s.lastInsert !== insertPoint) {
600 | var nodes = $.unique(dt.rows({ page: 'current' }).nodes().toArray());
601 | var insertPlacement = '';
602 |
603 | if (insertPoint > this.s.lastInsert) {
604 | this.dom.target.insertAfter(nodes[insertPoint - 1]);
605 | insertPlacement = 'after';
606 | }
607 | else {
608 | this.dom.target.insertBefore(nodes[insertPoint]);
609 | insertPlacement = 'before';
610 | }
611 |
612 | this._cachePositions();
613 |
614 | this.s.lastInsert = insertPoint;
615 |
616 | this._emitEvent('row-reorder-changed', {
617 | insertPlacement,
618 | insertPoint,
619 | row: dt.row(this.dom.target)
620 | });
621 | }
622 | },
623 |
624 | /**
625 | * Removes the cloned elements, event handlers, scrolling intervals, etc
626 | *
627 | * @private
628 | */
629 | _cleanupDragging: function () {
630 | var cancelable = this.c.cancelable;
631 |
632 | this.dom.clone.remove();
633 | this.dom.cloneParent.remove();
634 | this.dom.clone = null;
635 | this.dom.cloneParent = null;
636 |
637 | this.dom.target.removeClass('dt-rowReorder-moving');
638 | //this.dom.target = null;
639 |
640 | $(document).off('.rowReorder');
641 | $(document.body).removeClass('dt-rowReorder-noOverflow');
642 |
643 | clearInterval(this.s.scrollInterval);
644 | this.s.scrollInterval = null;
645 |
646 | if (cancelable) {
647 | $(document).off('keyup', this._keyup);
648 | }
649 | },
650 |
651 | /**
652 | * Move the window and DataTables scrolling during a drag to scroll new
653 | * content into view.
654 | *
655 | * This matches the `_shiftScroll` method used in AutoFill, but only
656 | * horizontal scrolling is considered here.
657 | *
658 | * @param {object} e Mouse move event object
659 | * @private
660 | */
661 | _shiftScroll: function (e) {
662 | var that = this;
663 | var scroll = this.s.scroll;
664 | var runInterval = false;
665 | var scrollSpeed = 5;
666 | var buffer = 65;
667 | var windowY = e.pageY - document.body.scrollTop,
668 | windowVert,
669 | dtVert;
670 |
671 | // Window calculations - based on the mouse position in the window,
672 | // regardless of scrolling
673 | if (windowY < $(window).scrollTop() + buffer) {
674 | windowVert = scrollSpeed * -1;
675 | }
676 | else if (windowY > scroll.windowHeight + $(window).scrollTop() - buffer) {
677 | windowVert = scrollSpeed;
678 | }
679 |
680 | // DataTables scrolling calculations - based on the table's position in
681 | // the document and the mouse position on the page
682 | if (scroll.dtTop !== null && e.pageY < scroll.dtTop + buffer) {
683 | dtVert = scrollSpeed * -1;
684 | }
685 | else if (scroll.dtTop !== null && e.pageY > scroll.dtTop + scroll.dtHeight - buffer) {
686 | dtVert = scrollSpeed;
687 | }
688 |
689 | // This is where it gets interesting. We want to continue scrolling
690 | // without requiring a mouse move, so we need an interval to be
691 | // triggered. The interval should continue until it is no longer needed,
692 | // but it must also use the latest scroll commands (for example consider
693 | // that the mouse might move from scrolling up to scrolling left, all
694 | // with the same interval running. We use the `scroll` object to "pass"
695 | // this information to the interval. Can't use local variables as they
696 | // wouldn't be the ones that are used by an already existing interval!
697 | if (windowVert || dtVert) {
698 | scroll.windowVert = windowVert;
699 | scroll.dtVert = dtVert;
700 | runInterval = true;
701 | }
702 | else if (this.s.scrollInterval) {
703 | // Don't need to scroll - remove any existing timer
704 | clearInterval(this.s.scrollInterval);
705 | this.s.scrollInterval = null;
706 | }
707 |
708 | // If we need to run the interval to scroll and there is no existing
709 | // interval (if there is an existing one, it will continue to run)
710 | if (!this.s.scrollInterval && runInterval) {
711 | this.s.scrollInterval = setInterval(function () {
712 | // Don't need to worry about setting scroll <0 or beyond the
713 | // scroll bound as the browser will just reject that.
714 | if (scroll.windowVert) {
715 | var top = $(document).scrollTop();
716 | $(document).scrollTop(top + scroll.windowVert);
717 |
718 | if (top !== $(document).scrollTop()) {
719 | var move = parseFloat(that.dom.cloneParent.css('top'));
720 | that.dom.cloneParent.css('top', move + scroll.windowVert);
721 | }
722 | }
723 |
724 | // DataTables scrolling
725 | if (scroll.dtVert) {
726 | var scroller = that.dom.dtScroll[0];
727 |
728 | if (scroll.dtVert) {
729 | scroller.scrollTop += scroll.dtVert;
730 | }
731 | }
732 | }, 20);
733 | }
734 | },
735 |
736 | /**
737 | * Calculates the current area of the table body and returns it as a rectangle
738 | *
739 | * @private
740 | */
741 | _calcBodyArea: function (e) {
742 | var dt = this.s.dt;
743 | var offset = $(dt.table().body()).offset();
744 | var area = {
745 | left: offset.left,
746 | top: offset.top,
747 | right: offset.left + $(dt.table().body()).width(),
748 | bottom: offset.top + $(dt.table().body()).height()
749 | };
750 |
751 | return area;
752 | },
753 |
754 | /**
755 | * Calculates the current area of the cloned parent element and returns it as a rectangle
756 | *
757 | * @private
758 | */
759 | _calcCloneParentArea: function (e) {
760 | var offset = $(this.dom.cloneParent).offset();
761 | var area = {
762 | left: offset.left,
763 | top: offset.top,
764 | right: offset.left + $(this.dom.cloneParent).width(),
765 | bottom: offset.top + $(this.dom.cloneParent).height()
766 | };
767 |
768 | return area;
769 | },
770 |
771 | /**
772 | * Returns whether the given reactangles intersect or not
773 | *
774 | * @private
775 | */
776 | _rectanglesIntersect: function (a, b) {
777 | var noOverlap =
778 | a.left >= b.right || b.left >= a.right || a.top >= b.bottom || b.top >= a.bottom;
779 |
780 | return !noOverlap;
781 | },
782 |
783 | /**
784 | * Calculates the index of the row which lays under the given Y position or
785 | * returns -1 if no such row
786 | *
787 | * @param {integer} insertPoint Position
788 | * @private
789 | */
790 | _calcRowIndexByPos: function (bodyY) {
791 | // Determine where the row is located based on the mouse
792 | // position
793 |
794 | var dt = this.s.dt;
795 | var nodes = $.unique(dt.rows({ page: 'current' }).nodes().toArray());
796 | var rowIndex = -1;
797 | var headerHeight = $(dt.table().node()).find('thead').outerHeight();
798 |
799 | $.each(nodes, function (i, node) {
800 | var top = $(node).position().top - headerHeight;
801 | var bottom = top + $(node).outerHeight();
802 |
803 | if (bodyY >= top && bodyY <= bottom) {
804 | rowIndex = i;
805 | }
806 | });
807 |
808 | return rowIndex;
809 | },
810 |
811 | /**
812 | * Handles key up events and cancels the dragging if ESC key is pressed
813 | *
814 | * @param {object} e Mouse move event object
815 | * @private
816 | */
817 | _keyup: function (e) {
818 | var cancelable = this.c.cancelable;
819 |
820 | if (cancelable && e.which === 27) {
821 | // ESC key is up
822 | e.preventDefault();
823 | this._cancel();
824 | }
825 | },
826 |
827 | /**
828 | * Cancels the dragging, moves target back into its original position
829 | * and cleans up the dragging
830 | *
831 | * @param {object} e Mouse move event object
832 | * @private
833 | */
834 | _cancel: function () {
835 | var start = this.s.start;
836 | var insertPoint = start.rowIndex > this.s.lastInsert ? start.rowIndex + 1 : start.rowIndex;
837 |
838 | this._moveTargetIntoPosition(insertPoint);
839 |
840 | this._cleanupDragging();
841 |
842 | // Emit event
843 | this._emitEvent('row-reorder-canceled', [this.s.start.rowIndex]);
844 | }
845 | });
846 |
847 | /**
848 | * RowReorder default settings for initialisation
849 | *
850 | * @namespace
851 | * @name RowReorder.defaults
852 | * @static
853 | */
854 | RowReorder.defaults = {
855 | /**
856 | * Data point in the host row's data source object for where to get and set
857 | * the data to reorder. This will normally also be the sorting column.
858 | *
859 | * @type {Number}
860 | */
861 | dataSrc: 0,
862 |
863 | /**
864 | * Editor instance that will be used to perform the update
865 | *
866 | * @type {DataTable.Editor}
867 | */
868 | editor: null,
869 |
870 | /**
871 | * Enable / disable RowReorder's user interaction
872 | * @type {Boolean}
873 | */
874 | enable: true,
875 |
876 | /**
877 | * Form options to pass to Editor when submitting a change in the row order.
878 | * See the Editor `from-options` object for details of the options
879 | * available.
880 | * @type {Object}
881 | */
882 | formOptions: {},
883 |
884 | /**
885 | * Drag handle selector. This defines the element that when dragged will
886 | * reorder a row.
887 | *
888 | * @type {String}
889 | */
890 | selector: 'td:first-child',
891 |
892 | /**
893 | * Optionally lock the dragged row's x-position. This can be `true` to
894 | * fix the position match the host table's, `false` to allow free movement
895 | * of the row, or a number to define an offset from the host table.
896 | *
897 | * @type {Boolean|number}
898 | */
899 | snapX: false,
900 |
901 | /**
902 | * Update the table's data on drop
903 | *
904 | * @type {Boolean}
905 | */
906 | update: true,
907 |
908 | /**
909 | * Selector for children of the drag handle selector that mouseDown events
910 | * will be passed through to and drag will not activate
911 | *
912 | * @type {String}
913 | */
914 | excludedChildren: 'a',
915 |
916 | /**
917 | * Enable / disable the canceling of the drag & drop interaction
918 | *
919 | * @type {Boolean}
920 | */
921 | cancelable: false
922 | };
923 |
924 | /*
925 | * API
926 | */
927 | var Api = $.fn.dataTable.Api;
928 |
929 | // Doesn't do anything - work around for a bug in DT... Not documented
930 | Api.register('rowReorder()', function () {
931 | return this;
932 | });
933 |
934 | Api.register('rowReorder.enable()', function (toggle) {
935 | if (toggle === undefined) {
936 | toggle = true;
937 | }
938 |
939 | return this.iterator('table', function (ctx) {
940 | if (ctx.rowreorder) {
941 | ctx.rowreorder.c.enable = toggle;
942 | }
943 | });
944 | });
945 |
946 | Api.register('rowReorder.disable()', function () {
947 | return this.iterator('table', function (ctx) {
948 | if (ctx.rowreorder) {
949 | ctx.rowreorder.c.enable = false;
950 | }
951 | });
952 | });
953 |
954 | /**
955 | * Version information
956 | *
957 | * @name RowReorder.version
958 | * @static
959 | */
960 | RowReorder.version = '1.5.0';
961 |
962 | $.fn.dataTable.RowReorder = RowReorder;
963 | $.fn.DataTable.RowReorder = RowReorder;
964 |
965 | // Attach a listener to the document which listens for DataTables initialisation
966 | // events so we can automatically initialise
967 | $(document).on('init.dt.dtr', function (e, settings, json) {
968 | if (e.namespace !== 'dt') {
969 | return;
970 | }
971 |
972 | var init = settings.oInit.rowReorder;
973 | var defaults = DataTable.defaults.rowReorder;
974 |
975 | if (init || defaults) {
976 | var opts = $.extend({}, init, defaults);
977 |
978 | if (init !== false) {
979 | new RowReorder(settings, opts);
980 | }
981 | }
982 | });
983 |
--------------------------------------------------------------------------------
/js/rowReorder.bootstrap.js:
--------------------------------------------------------------------------------
1 | /*! Bootstrap 3 styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
5 |
--------------------------------------------------------------------------------
/js/rowReorder.bootstrap4.js:
--------------------------------------------------------------------------------
1 | /*! Bootstrap 4 styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.bootstrap5.js:
--------------------------------------------------------------------------------
1 | /*! Bootstrap 5 styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.bulma.js:
--------------------------------------------------------------------------------
1 | /*! Bulma styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.dataTables.js:
--------------------------------------------------------------------------------
1 | /*! DataTables styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.foundation.js:
--------------------------------------------------------------------------------
1 | /*! Foundation styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.jqueryui.js:
--------------------------------------------------------------------------------
1 | /*! jQuery UI styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/js/rowReorder.semanticui.js:
--------------------------------------------------------------------------------
1 | /*! Semanic UI styling wrapper for RowReorder
2 | * © SpryMedia Ltd - datatables.net/license
3 | */
4 |
--------------------------------------------------------------------------------
/make.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | DT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../.."
4 | if [ "$1" = "debug" ]; then
5 | DEBUG="debug"
6 | else
7 | OUT_DIR=$1
8 | DEBUG=$2
9 | fi
10 |
11 | # If not run from DataTables build script, redirect to there
12 | if [ -z "$DT_BUILD" ]; then
13 | cd $DT_DIR/build
14 | ./make.sh extension RowReorder $DEBUG
15 | cd -
16 | exit
17 | fi
18 |
19 | # Change into script's own dir
20 | cd $(dirname $0)
21 |
22 | DT_SRC=$(dirname $(dirname $(pwd)))
23 | DT_BUILT="${DT_SRC}/built/DataTables"
24 | . $DT_SRC/build/include.sh
25 |
26 | # Copy CSS
27 | rsync -r css $OUT_DIR
28 | css_frameworks rowReorder $OUT_DIR/css
29 |
30 | # Copy JS
31 | rsync -r js $OUT_DIR
32 | js_wrap $OUT_DIR/js/dataTables.rowReorder.js "jquery datatables.net"
33 | js_frameworks rowReorder $OUT_DIR/js "jquery datatables.net-FW datatables.net-rowreorder"
34 |
35 |
36 | # Copy Types
37 | if [ -d $OUT_DIR/types ]; then
38 | rm -r $OUT_DIR/types
39 | fi
40 | mkdir $OUT_DIR/types
41 |
42 | if [ -d types/ ]; then
43 | cp types/* $OUT_DIR/types
44 | else
45 | if [ -f types.d.ts ]; then
46 | cp types.d.ts $OUT_DIR/types
47 | fi
48 | fi
49 |
50 | # Copy and build examples
51 | rsync -r examples $OUT_DIR
52 | examples_process $OUT_DIR/examples
53 |
54 | # Readme and license
55 | cp Readme.md $OUT_DIR
56 | cp License.txt $OUT_DIR
57 |
58 |
--------------------------------------------------------------------------------
/types/rowReorder.bootstrap.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.bootstrap4.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.bootstrap5.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.bulma.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.dataTables.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.foundation.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.jqueryui.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/rowReorder.semanticui.d.ts:
--------------------------------------------------------------------------------
1 |
2 | import DataTable from 'datatables.net-rowreorder';
3 |
4 | export default DataTable;
5 | export * from 'datatables.net-rowreorder';
6 |
--------------------------------------------------------------------------------
/types/types.d.ts:
--------------------------------------------------------------------------------
1 | // Type definitions for DataTables RowReorder
2 | //
3 | // Project: https://datatables.net/extensions/rowreorder/, https://datatables.net
4 | // Definitions by:
5 | // SpryMedia
6 | // Vincent Biret
7 |
8 | import DataTables, {Api} from 'datatables.net';
9 |
10 | export default DataTables;
11 |
12 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
13 | * DataTables' types integration
14 | */
15 | declare module 'datatables.net' {
16 | interface Config {
17 | /**
18 | * RowReorder extension options
19 | */
20 | rowReorder?: boolean | ConfigRowReorder;
21 | }
22 |
23 | interface Api {
24 | /**
25 | * RowReorder methods container
26 | *
27 | * @returns Api for chaining with the additional RowReorder methods
28 | */
29 | rowReorder: ApiRowReorderMethods;
30 | }
31 |
32 | interface DataTablesStatic {
33 | /**
34 | * RowReorder class
35 | */
36 | RowReorder: {
37 | /**
38 | * Create a new RowReorder instance for the target DataTable
39 | */
40 | new (dt: Api, settings: boolean | ConfigRowReorder): DataTablesStatic['RowReorder'];
41 |
42 | /**
43 | * RowReorder version
44 | */
45 | version: string;
46 |
47 | /**
48 | * Default configuration values
49 | */
50 | defaults: ConfigRowReorder;
51 | }
52 | }
53 | }
54 |
55 |
56 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57 | * Options
58 | */
59 |
60 | interface ConfigRowReorder {
61 | /**
62 | * Configure the data point that will be used for the reordering data
63 | */
64 | dataSrc?: string;
65 |
66 | /**
67 | * Attach an Editor instance for database updating
68 | */
69 | editor?: any;
70 |
71 | /**
72 | * Enable / disable RowReorder's user interaction
73 | */
74 | enable?: boolean;
75 |
76 | /**
77 | * Set the options for the Editor form when submitting data
78 | */
79 | formOptions?: any;
80 |
81 | /**
82 | * Define the selector used to pick the elements that will start a drag
83 | */
84 | selector?: string;
85 |
86 | /**
87 | * Horizontal position control of the row being dragged
88 | */
89 | snapX?: number | boolean;
90 |
91 | /**
92 | * Control automatic of data when a row is dropped
93 | */
94 | update?: boolean;
95 | }
96 |
97 |
98 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
99 | * API
100 | */
101 |
102 | interface ApiRowReorderMethods extends Api {
103 | /**
104 | * Disable the end user's ability to click and drag to reorder rows.
105 | *
106 | * @returns DataTables API instance
107 | */
108 | disable(): Api;
109 |
110 | /**
111 | * Enable, or optionally disable, the end user's ability to click and drag to reorder rows.
112 | *
113 | * @param enable that can be used to indicate if row reordering should be enabled or disabled.
114 | * @returns DataTables API instance
115 | */
116 | enable(enable?: boolean): Api;
117 | }
118 |
--------------------------------------------------------------------------------