MCPcopy Create free account
hub / github.com/blockstrap/framework / _fnCreateTr

Function _fnCreateTr

blockstrap/js/dependencies/tables.js:1548–1616  ·  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

1546 * @memberof DataTable#oApi
1547 */
1548 function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
1549 {
1550 var
1551 row = oSettings.aoData[iRow],
1552 rowData = row._aData,
1553 cells = [],
1554 nTr, nTd, oCol,
1555 i, iLen;
1556
1557 if ( row.nTr === null )
1558 {
1559 nTr = nTrIn || document.createElement('tr');
1560
1561 row.nTr = nTr;
1562 row.anCells = cells;
1563
1564 /* Use a private property on the node to allow reserve mapping from the node
1565 * to the aoData array for fast look up
1566 */
1567 nTr._DT_RowIndex = iRow;
1568
1569 /* Special parameters can be given by the data source to be used on the row */
1570 _fnRowAttributes( row );
1571
1572 /* Process each column */
1573 for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
1574 {
1575 oCol = oSettings.aoColumns[i];
1576
1577 nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
1578 cells.push( nTd );
1579
1580 // Need to create the HTML if new, or if a rendering function is defined
1581 if ( !nTrIn || oCol.mRender || oCol.mData !== i )
1582 {
1583 nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
1584 }
1585
1586 /* Add user defined class */
1587 if ( oCol.sClass )
1588 {
1589 nTd.className += ' '+oCol.sClass;
1590 }
1591
1592 // Visibility - add or remove as required
1593 if ( oCol.bVisible && ! nTrIn )
1594 {
1595 nTr.appendChild( nTd );
1596 }
1597 else if ( ! oCol.bVisible && nTrIn )
1598 {
1599 nTd.parentNode.removeChild( nTd );
1600 }
1601
1602 if ( oCol.fnCreatedCell )
1603 {
1604 oCol.fnCreatedCell.call( oSettings.oInstance,
1605 nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), rowData, iRow, i

Callers 2

_fnAddDataFunction · 0.85
_fnDrawFunction · 0.85

Calls 3

_fnRowAttributesFunction · 0.85
_fnGetCellDataFunction · 0.85
_fnCallbackFireFunction · 0.85

Tested by

no test coverage detected