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

Function _fnBuildHead

external/.datatables.js:2967–3018  ·  view source on GitHub ↗

* Create the HTML header for the table * @param {object} oSettings dataTables settings object * @memberof DataTable#oApi

(settings, side)

Source from the content-addressed store, hash-verified

2965 * @memberof DataTable#oApi
2966 */
2967 function _fnBuildHead(settings, side) {
2968 var classes = settings.oClasses
2969 var columns = settings.aoColumns
2970 var i, ien, row
2971 var target = side === "header" ? settings.nTHead : settings.nTFoot
2972 var titleProp = side === "header" ? "sTitle" : side
2973
2974 // Footer might be defined
2975 if (!target) {
2976 return
2977 }
2978
2979 // If no cells yet and we have content for them, then create
2980 if (side === "header" || _pluck(settings.aoColumns, titleProp).join("")) {
2981 row = $("tr", target)
2982
2983 // Add a row if needed
2984 if (!row.length) {
2985 row = $("<tr/>").appendTo(target)
2986 }
2987
2988 // Add the number of cells needed to make up to the number of columns
2989 if (row.length === 1) {
2990 var cells = $("td, th", row)
2991
2992 for (i = cells.length, ien = columns.length; i < ien; i++) {
2993 $("<th/>")
2994 .html(columns[i][titleProp] || "")
2995 .appendTo(row)
2996 }
2997 }
2998 }
2999
3000 var detected = _fnDetectHeader(settings, target, true)
3001
3002 if (side === "header") {
3003 settings.aoHeader = detected
3004 } else {
3005 settings.aoFooter = detected
3006 }
3007
3008 // ARIA role for the rows
3009 $(target).children("tr").attr("role", "row")
3010
3011 // Every cell needs to be passed through the renderer
3012 $(target)
3013 .children("tr")
3014 .children("th, td")
3015 .each(function () {
3016 _fnRenderer(settings, side)(settings, $(this), classes)
3017 })
3018 }
3019
3020 /**
3021 * Build a layout structure for a header or footer

Callers 1

_fnInitialiseFunction · 0.85

Calls 6

_pluckFunction · 0.85
_fnDetectHeaderFunction · 0.85
_fnRendererFunction · 0.85
eachMethod · 0.80
$Function · 0.70
joinMethod · 0.45

Tested by

no test coverage detected