in js/vnext/projection/cells.js [17:98]
function translateRow({
columnGroup,
row,
rowType,
primaryKey,
}) {
const patch = {};
if (_.has(row, 'html')) {
patch.cells = [{
attributes: {
rowspan: 1,
colspan: columnGroup.width,
},
html: row.html,
}];
}
if (_.has(row, 'view')) {
patch.cells = [{
attributes: {
rowspan: 1,
colspan: columnGroup.width,
},
view: row.view,
}];
}
if (_.has(row, 'item')) {
patch.cells = _.map(columnGroup.leafColumns, col => {
let cellClasses, cellAttributes;
if (rowType === 'foot') {
cellClasses = normalizeClasses(col.footClasses, row);
cellAttributes = normalizeAttributes(col.footAttributes, row);
} else if (rowType === 'body') {
cellClasses = normalizeClasses(col.bodyClasses, row);
cellAttributes = normalizeAttributes(col.bodyAttributes, row);
} else if (rowType === 'head') {
cellClasses = normalizeClasses(col.headClasses, row);
cellAttributes = normalizeAttributes(col.headAttributes, row);
}
/**
* The object represents a cell.
* @typedef CellContent
* @type {Object}
* @property {string[]} classes
* The classes for the `TD`/`TH` element
* @property {Object.<string,string>} attributes
* The HTML attributes for the `TD`/`TH` element.
* @property {string} html
* The HTML string to be rendered inside the cell.
* @property {Backbone.View} view
* The Backbone View to be filled into the cell. Unsupported for
* the body cells.
* @property {string} group [group=other]
* Group name.
* A Row will be separated by the group name. [[cell, cell], [cell], [cell]]
*/
const cell = { classes: cellClasses, attributes: cellAttributes };
cell.value = col.property.get(row.item);
cell.html = col.template(_.pick(cell, 'value'));
cell.group = _.result(columnGroup.columnIndex[col.name], 'group', 'other');
return cell;
});
patch.attributes = _.defaults({
'data-key': row.item[primaryKey],
}, row.attributes);
}
/**
* Extends the {@link RowConfig} with extra properties
* @typedef RowContent
* @type {RowConfig}
* @property {CellContent[]} cells
* The cells in the row.
* @property {Object.<string,string>} attributes
* The HTML attributes for the `TR` element.
*/
return _.defaults(patch, row, { attributes: {} });
}