MCPcopy Create free account
hub / github.com/breck7/scroll / headerUpdate

Function headerUpdate

external/.datatables.js:17194–17217  ·  view source on GitHub ↗

* Manipulate a header / footer array in DataTables settings to reorder * the columns.

(structure, map, from, to)

Source from the content-addressed store, hash-verified

17192 * the columns.
17193 */
17194 function headerUpdate(structure, map, from, to) {
17195 var done = []
17196 for (var i = 0; i < structure.length; i++) {
17197 var headerRow = structure[i]
17198 arrayMove(headerRow, from[0], from.length, to)
17199 for (var j = 0; j < headerRow.length; j++) {
17200 var cell = headerRow[j].cell
17201 // Only work on a DOM element once, otherwise we risk remapping a
17202 // remapped value (etc).
17203 if (done.includes(cell)) {
17204 continue
17205 }
17206 var indexes = cell.getAttribute("data-dt-column").split(",")
17207 var mapped = indexes
17208 .map(function (idx) {
17209 return map[idx]
17210 })
17211 .join(",")
17212 // Update data attributes for the new column position
17213 cell.setAttribute("data-dt-column", mapped)
17214 done.push(cell)
17215 }
17216 }
17217 }
17218 /**
17219 * Setup for ColReorder API operations
17220 *

Callers 1

moveFunction · 0.85

Calls 5

arrayMoveFunction · 0.85
splitMethod · 0.80
getAttributeMethod · 0.80
mapMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected