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

Function __setColumnVis

external/.datatables.js:7933–7980  ·  view source on GitHub ↗
(settings, column, vis)

Source from the content-addressed store, hash-verified

7931 }
7932
7933 var __setColumnVis = function (settings, column, vis) {
7934 var cols = settings.aoColumns,
7935 col = cols[column],
7936 data = settings.aoData,
7937 cells,
7938 i,
7939 ien,
7940 tr
7941
7942 // Get
7943 if (vis === undefined) {
7944 return col.bVisible
7945 }
7946
7947 // Set
7948 // No change
7949 if (col.bVisible === vis) {
7950 return false
7951 }
7952
7953 if (vis) {
7954 // Insert column
7955 // Need to decide if we should use appendChild or insertBefore
7956 var insertBefore = _pluck(cols, "bVisible").indexOf(true, column + 1)
7957
7958 for (i = 0, ien = data.length; i < ien; i++) {
7959 if (data[i]) {
7960 tr = data[i].nTr
7961 cells = data[i].anCells
7962
7963 if (tr) {
7964 // insertBefore can act like appendChild if 2nd arg is null
7965 tr.insertBefore(cells[column], cells[insertBefore] || null)
7966 }
7967 }
7968 }
7969 } else {
7970 // Remove column
7971 $(_pluck(settings.aoData, "anCells", column)).detach()
7972 }
7973
7974 // Common actions
7975 col.bVisible = vis
7976
7977 _colGroup(settings)
7978
7979 return true
7980 }
7981
7982 _api_register("columns()", function (selector, opts) {
7983 // argument shifting

Callers 1

.datatables.jsFile · 0.85

Calls 4

_pluckFunction · 0.85
_colGroupFunction · 0.85
indexOfMethod · 0.80
$Function · 0.70

Tested by

no test coverage detected