UNPKG

gd-sprest-js

Version:

SharePoint 2013/Online js components.

47 lines (46 loc) 1.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Table */ exports.Table = function (props) { var columns = props.columns || []; var rows = props.rows || []; // Set the class name var className = [ props.className || "", props.isFixed ? "ms-Table--fixed" : "", props.isSelectable ? "ms-Table--selectable" : "" ].join(' ').trim(); // See if we are rendering the header row var headerRow = props.renderHeaderRow ? [ '<thead>', '<tr>', '<th>' + columns.join('</th><th>') + '</th>', '</tr>', '</thead>' ].join('\n') : ""; // Parse the rows var rowData = []; for (var i = 0; i < rows.length; i++) { var row = rows[i]; // Add the opening row element rowData.push('<tr>'); // Parse the columns for (var j = 0; j < columns.length; j++) { // Add the column element rowData.push('<td>' + (row[columns[j]] || "") + '</td>'); } // Add the closing row element rowData.push('</tr>'); } // Return the template return [ '<table class="ms-Table ' + className + '">', headerRow, '<tbody>', rowData.join('\n'), '</tbody>', '</table>' ].join('\n'); };