* Build a layout structure for a header or footer * * @param {*} settings DataTables settings * @param {*} source Source layout array * @param {*} incColumns What columns should be included * @returns Layout array
(settings, source, incColumns)
| 3026 | * @returns Layout array |
| 3027 | */ |
| 3028 | function _fnHeaderLayout(settings, source, incColumns) { |
| 3029 | var row, column, cell |
| 3030 | var local = [] |
| 3031 | var structure = [] |
| 3032 | var columns = settings.aoColumns |
| 3033 | var columnCount = columns.length |
| 3034 | var rowspan, colspan |
| 3035 | |
| 3036 | if (!source) { |
| 3037 | return |
| 3038 | } |
| 3039 | |
| 3040 | // Default is to work on only visible columns |
| 3041 | if (!incColumns) { |
| 3042 | incColumns = _range(columnCount).filter(function (idx) { |
| 3043 | return columns[idx].bVisible |
| 3044 | }) |
| 3045 | } |
| 3046 | |
| 3047 | // Make a copy of the master layout array, but with only the columns we want |
| 3048 | for (row = 0; row < source.length; row++) { |
| 3049 | // Remove any columns we haven't selected |
| 3050 | local[row] = source[row].slice().filter(function (cell, i) { |
| 3051 | return incColumns.includes(i) |
| 3052 | }) |
| 3053 | |
| 3054 | // Prep the structure array - it needs an element for each row |
| 3055 | structure.push([]) |
| 3056 | } |
| 3057 | |
| 3058 | for (row = 0; row < local.length; row++) { |
| 3059 | for (column = 0; column < local[row].length; column++) { |
| 3060 | rowspan = 1 |
| 3061 | colspan = 1 |
| 3062 | |
| 3063 | // Check to see if there is already a cell (row/colspan) covering our target |
| 3064 | // insert point. If there is, then there is nothing to do. |
| 3065 | if (structure[row][column] === undefined) { |
| 3066 | cell = local[row][column].cell |
| 3067 | |
| 3068 | // Expand for rowspan |
| 3069 | while (local[row + rowspan] !== undefined && local[row][column].cell == local[row + rowspan][column].cell) { |
| 3070 | structure[row + rowspan][column] = null |
| 3071 | rowspan++ |
| 3072 | } |
| 3073 | |
| 3074 | // And for colspan |
| 3075 | while (local[row][column + colspan] !== undefined && local[row][column].cell == local[row][column + colspan].cell) { |
| 3076 | // Which also needs to go over rows |
| 3077 | for (var k = 0; k < rowspan; k++) { |
| 3078 | structure[row + k][column + colspan] = null |
| 3079 | } |
| 3080 | |
| 3081 | colspan++ |
| 3082 | } |
| 3083 | |
| 3084 | var titleSpan = $("span.dt-column-title", cell) |
| 3085 |
no test coverage detected