Basic column reorder
This example shows the basic use case of the ColReorderplugin. With ColReorder enabled for a table, the user has the ability to click and drag any table header cell, and drop it where they wish the column to be inserted. The insert point is shown visually, and the column reordering is done as soon as the mouse button is released. ColReorder is added to a DataTable through the Rcharacter added to the dom.
First Name Last Name Job Title DOB Status Actions
Marth Enright Traffic Court Referee 22 Jun 1972 Active
Jackelyn Weible Airline Transport Pilot 3 Oct 1981 Inactive
Aura Hard Business Services Sales Representative 19 Apr 1969 Suspended
Nathalie Pretty Drywall Stripper 13 Dec 1977 Pending
Sharan Leland Aviation Tactical Readiness Officer 30 Dec 1991 Inactive
Maxine Woldt Business Services Sales Representative 17 Oct 1987 Pending
Sylvia Mcgaughy Hemodialysis Technician 11 Nov 1983 Suspended
Lizzee Goodlow Technical Services Librarian 1 Nov 1961 Suspended
Kennedy Haley Senior Marketing Designer 18 Dec 1960 Active
Chantal Nailor Technical Services Librarian 10 Jan 1980 Inactive
Delma Bonds Lead Brand Manager 21 Dec 1968 Pending
Roland Salmos Senior Program Developer 5 Jun 1986 Inactive
Coy Wollard Customer Service Operator 12 Oct 1982 Active
Maxwell Maben Regional Representative 25 Feb 1988 Suspended
Cicely Sigler Senior Research Officer 15 Mar 1960 Pending
Realtime updating
While the ColReorder insertion point indicator can be styled, another option to show the end user what the column will look like when the table has been reordered is to actually do the reordering while the mouse is still dragging the column header. This is shown in this example and is controlled by the realtimeparameter.
First Name Last Name Job Title DOB Status Actions
Marth Enright Traffic Court Referee 22 Jun 1972 Active
Jackelyn Weible Airline Transport Pilot 3 Oct 1981 Inactive
Aura Hard Business Services Sales Representative 19 Apr 1969 Suspended
Nathalie Pretty Drywall Stripper 13 Dec 1977 Pending
Sharan Leland Aviation Tactical Readiness Officer 30 Dec 1991 Inactive
Maxine Woldt Business Services Sales Representative 17 Oct 1987 Pending
Sylvia Mcgaughy Hemodialysis Technician 11 Nov 1983 Suspended
Lizzee Goodlow Technical Services Librarian 1 Nov 1961 Suspended
Kennedy Haley Senior Marketing Designer 18 Dec 1960 Active
Chantal Nailor Technical Services Librarian 10 Jan 1980 Inactive
Delma Bonds Lead Brand Manager 21 Dec 1968 Pending
Roland Salmos Senior Program Developer 5 Jun 1986 Inactive
Coy Wollard Customer Service Operator 12 Oct 1982 Active
Maxwell Maben Regional Representative 25 Feb 1988 Suspended
Cicely Sigler Senior Research Officer 15 Mar 1960 Pending
State saving
A useful interaction pattern to use in DataTables is state saving, so when the end user reloads or revisits a page its previous state is retained. ColReorder works seamlessly with state saving in DataTables (stateSave), remembering and restoring the column positions, as well as everything else such as sorting and filtering.
First Name Last Name Job Title DOB Status Actions
Marth Enright Traffic Court Referee 22 Jun 1972 Active
Jackelyn Weible Airline Transport Pilot 3 Oct 1981 Inactive
Aura Hard Business Services Sales Representative 19 Apr 1969 Suspended
Nathalie Pretty Drywall Stripper 13 Dec 1977 Pending
Sharan Leland Aviation Tactical Readiness Officer 30 Dec 1991 Inactive
Maxine Woldt Business Services Sales Representative 17 Oct 1987 Pending
Sylvia Mcgaughy Hemodialysis Technician 11 Nov 1983 Suspended
Lizzee Goodlow Technical Services Librarian 1 Nov 1961 Suspended
Kennedy Haley Senior Marketing Designer 18 Dec 1960 Active
Chantal Nailor Technical Services Librarian 10 Jan 1980 Inactive
Delma Bonds Lead Brand Manager 21 Dec 1968 Pending
Roland Salmos Senior Program Developer 5 Jun 1986 Inactive
Coy Wollard Customer Service Operator 12 Oct 1982 Active
Maxwell Maben Regional Representative 25 Feb 1988 Suspended
Cicely Sigler Senior Research Officer 15 Mar 1960 Pending
Predefined column ordering
ColReorder provides the ability to specify a column ordering which is not that of the HTML (which typically you will want) through the parameter colReorder.order. This is an array of integers with the column ordering you want. In this example columns are ordered on initalization this way: 1, 3, 2, 4, 0, 5, ordering functionality remains working even after predefined ordering.
First Name Last Name Job Title DOB Status Actions
Marth Enright Traffic Court Referee 22 Jun 1972 Active
Jackelyn Weible Airline Transport Pilot 3 Oct 1981 Inactive
Aura Hard Business Services Sales Representative 19 Apr 1969 Suspended
Nathalie Pretty Drywall Stripper 13 Dec 1977 Pending
Sharan Leland Aviation Tactical Readiness Officer 30 Dec 1991 Inactive
Maxine Woldt Business Services Sales Representative 17 Oct 1987 Pending
Sylvia Mcgaughy Hemodialysis Technician 11 Nov 1983 Suspended
Lizzee Goodlow Technical Services Librarian 1 Nov 1961 Suspended
Kennedy Haley Senior Marketing Designer 18 Dec 1960 Active
Chantal Nailor Technical Services Librarian 10 Jan 1980 Inactive
Delma Bonds Lead Brand Manager 21 Dec 1968 Pending
Roland Salmos Senior Program Developer 5 Jun 1986 Inactive
Coy Wollard Customer Service Operator 12 Oct 1982 Active
Maxwell Maben Regional Representative 25 Feb 1988 Suspended
Cicely Sigler Senior Research Officer 15 Mar 1960 Pending