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

Function _fnCreateTr

external/.datatables.js:2852–2924  ·  view source on GitHub ↗

* Create a new TR element (and it's TD children) for a row * @param {object} oSettings dataTables settings object * @param {int} iRow Row to consider * @param {node} [nTrIn] TR element to add to the table - optional. If not given, * DataTables will create a row automatically * @para

(oSettings, iRow, nTrIn, anTds)

Source from the content-addressed store, hash-verified

2850 * @memberof DataTable#oApi
2851 */
2852 function _fnCreateTr(oSettings, iRow, nTrIn, anTds) {
2853 var row = oSettings.aoData[iRow],
2854 rowData = row._aData,
2855 cells = [],
2856 nTr,
2857 nTd,
2858 oCol,
2859 i,
2860 iLen,
2861 create,
2862 trClass = oSettings.oClasses.tbody.row
2863
2864 if (row.nTr === null) {
2865 nTr = nTrIn || document.createElement("tr")
2866
2867 row.nTr = nTr
2868 row.anCells = cells
2869
2870 _addClass(nTr, trClass)
2871
2872 /* Use a private property on the node to allow reserve mapping from the node
2873 * to the aoData array for fast look up
2874 */
2875 nTr._DT_RowIndex = iRow
2876
2877 /* Special parameters can be given by the data source to be used on the row */
2878 _fnRowAttributes(oSettings, row)
2879
2880 /* Process each column */
2881 for (i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
2882 oCol = oSettings.aoColumns[i]
2883 create = nTrIn && anTds[i] ? false : true
2884
2885 nTd = create ? document.createElement(oCol.sCellType) : anTds[i]
2886
2887 if (!nTd) {
2888 _fnLog(oSettings, 0, "Incorrect column count", 18)
2889 }
2890
2891 nTd._DT_CellIndex = {
2892 row: iRow,
2893 column: i
2894 }
2895
2896 cells.push(nTd)
2897
2898 var display = _fnGetRowDisplay(oSettings, iRow)
2899
2900 // Need to create the HTML if new, or if a rendering function is defined
2901 if (create || ((oCol.mRender || oCol.mData !== i) && (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i + ".display"))) {
2902 _fnWriteCell(nTd, display[i])
2903 }
2904
2905 // column class
2906 _addClass(nTd, oCol.sClass)
2907
2908 // Visibility - add or remove as required
2909 if (oCol.bVisible && create) {

Callers 2

_fnAddDataFunction · 0.85
_fnDrawFunction · 0.85

Calls 7

_addClassFunction · 0.85
_fnRowAttributesFunction · 0.85
_fnLogFunction · 0.85
_fnGetRowDisplayFunction · 0.85
_fnWriteCellFunction · 0.85
_fnGetCellDataFunction · 0.85
_fnCallbackFireFunction · 0.85

Tested by

no test coverage detected