Skip to content

Commit

Permalink
Fix primefaces#3642: RowGroupHeaderTemplate allow custom rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Nov 15, 2022
1 parent 08ffbf1 commit 4e6dc7b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions components/lib/datatable/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,14 +813,22 @@ export const TableBody = React.memo(
if (isSubheaderGrouping && shouldRenderRowGroupHeader(props.value, rowData, index - props.first)) {
const style = rowGroupHeaderStyle();
const toggler = props.expandableRowGroups && <RowTogglerButton onClick={onRowToggle} rowData={rowData} expanded={expanded} expandedRowIcon={props.expandedRowIcon} collapsedRowIcon={props.collapsedRowIcon} />;
const content = ObjectUtils.getJSXElement(props.rowGroupHeaderTemplate, rowData, { index, props: props.tableProps });
const options = { index, index, props: props.tableProps, customRendering: false };
const content = ObjectUtils.getJSXElement(props.rowGroupHeaderTemplate, rowData, options);

return (
<tr className="p-rowgroup-header" style={style} role="row">
// check if the user wants complete control of the rendering
if (!options.customRendering) {
content = (
<td colSpan={colSpan}>
{toggler}
<span className="p-rowgroup-header-name">{content}</span>
</td>
);
}

return (
<tr className="p-rowgroup-header" style={style} role="row">
{content}
</tr>
);
}
Expand Down
1 change: 1 addition & 0 deletions components/lib/datatable/datatable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ interface DataTableFooterTemplateOptions extends DataTableHeaderTemplateOptions
interface DataTableRowGroupHeaderTemplateOptions {
index: number;
props: DataTableProps;
customRendering: boolean;
}

interface DataTableRowGroupFooterTemplateOptions extends DataTableRowGroupHeaderTemplateOptions {
Expand Down

0 comments on commit 4e6dc7b

Please sign in to comment.