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

Function _fnGetMaxLenString

external/.datatables.js:5086–5118  ·  view source on GitHub ↗

* Get the maximum strlen for each data column * @param {object} settings dataTables settings object * @param {int} colIdx column of interest * @returns {string} string of the max length * @memberof DataTable#oApi

(settings, colIdx)

Source from the content-addressed store, hash-verified

5084 * @memberof DataTable#oApi
5085 */
5086 function _fnGetMaxLenString(settings, colIdx) {
5087 var column = settings.aoColumns[colIdx]
5088
5089 if (!column.maxLenString) {
5090 var s,
5091 max = "",
5092 maxLen = -1
5093
5094 for (var i = 0, ien = settings.aiDisplayMaster.length; i < ien; i++) {
5095 var rowIdx = settings.aiDisplayMaster[i]
5096 var data = _fnGetRowDisplay(settings, rowIdx)[colIdx]
5097
5098 var cellString = data && typeof data === "object" && data.nodeType ? data.innerHTML : data + ""
5099
5100 // Remove id / name attributes from elements so they
5101 // don't interfere with existing elements
5102 cellString = cellString.replace(/id=".*?"/g, "").replace(/name=".*?"/g, "")
5103
5104 s = _stripHtml(cellString).replace(/&nbsp;/g, " ")
5105
5106 if (s.length > maxLen) {
5107 // We want the HTML in the string, but the length that
5108 // is important is the stripped string
5109 max = cellString
5110 maxLen = s.length
5111 }
5112 }
5113
5114 column.maxLenString = max
5115 }
5116
5117 return column.maxLenString
5118 }
5119
5120 /**
5121 * Append a CSS unit (only if required) to a string

Callers 1

_fnCalculateColumnWidthsFunction · 0.85

Calls 3

_fnGetRowDisplayFunction · 0.85
_stripHtmlFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected