Skip to content

Commit

Permalink
Fix primefaces#3946: TreeTable allow header to be template
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 11, 2023
1 parent 0dc921f commit 436de2a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/lib/treetable/TreeTableHeader.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { InputText } from '../inputtext/InputText';
import { Tooltip } from '../tooltip/Tooltip';
import { classNames, DomHandler, ObjectUtils } from '../utils/Utils';
import { DomHandler, ObjectUtils, classNames } from '../utils/Utils';

export const TreeTableHeader = React.memo((props) => {
const filterTimeout = React.useRef(null);
Expand Down Expand Up @@ -174,6 +174,12 @@ export const TreeTableHeader = React.memo((props) => {
return null;
};

const createTitle = (column, options) => {
const title = ObjectUtils.getJSXElement(getColumnProp(column, 'header'), { props: options });

return <span className="p-column-title">{title}</span>;
};

const createHeaderCell = (column, options) => {
let filterElement;

Expand Down Expand Up @@ -226,7 +232,7 @@ export const TreeTableHeader = React.memo((props) => {

const headerTooltip = column.props.headerTooltip;
const hasTooltip = ObjectUtils.isNotEmpty(headerTooltip);

const title = createTitle(column, options);
const resizer = createResizer(column);

return (
Expand All @@ -248,7 +254,7 @@ export const TreeTableHeader = React.memo((props) => {
onDrop={(e) => onDrop(e, column)}
>
{resizer}
<span className="p-column-title">{column.props.header}</span>
{title}
{sortIconElement}
{sortBadge}
{filterElement}
Expand Down

0 comments on commit 436de2a

Please sign in to comment.