Skip to content

Commit

Permalink
onRenderHeader & ariaLabel on IColumn
Browse files Browse the repository at this point in the history
  • Loading branch information
tandrasi committed Sep 13, 2023
1 parent 3bc8d3c commit abd630d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Updates include:
>- "dropdownValues" prop on IColumnConfig can now be a function that returns IDropdownOption[]. It accepts an "item" parameter so tailor-made dropdown options for an item are possible based on any its other properties.
>- "editableOnlyInPanel" prop on IColumnConfig allows the column to only be editable in the panel (i.e. when the "Edit Panel" is open) when the "editable" prop is "true". "editable", "editableOnlyInPanel", and not "editable" columns on the grid now have CSS classes of "editable", "editable-panel-only", and "non-editable" added to their TooltipHost class names, respectively. TooltipHost class name is "cell-value".
>- "panelEditDisabledUntil" prop on IColumnConfig allows custom disabling of fields in the add/edit panels based on other values.
>- "onRenderHeader" and "ariaLabel" now available for use from IColumns definitions.
### Bug Fixes

Expand Down
33 changes: 32 additions & 1 deletion src/Examples/gridconsumer/gridconfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { EditControlType } from "../../libs/types/editcontroltype";
import { CellHover } from "./hoverComponent";
import { DataType } from "../../libs/types/datatype";
import { IDetailsColumnStyles } from "office-ui-fabric-react";
import { Icon, TooltipHost, mergeStyles } from '@fluentui/react';

const headerStyle: Partial<IDetailsColumnStyles> = { cellTitle: { backgroundColor: "rgb(0, 120, 212)", color: "#fff" }, sortIcon: { color: '#fff' } };

Expand Down Expand Up @@ -69,7 +70,37 @@ export const GridColumnConfig: IColumnConfig[] =
isResizable: true,
includeColumnInExport: true,
includeColumnInSearch: true,
applyColumnFilter: true
applyColumnFilter: true,
ariaLabel: 'Custom hover title',
headerClassName: mergeStyles({
'.ms-DetailsHeader-cellTitle,.ms-DetailsHeader-cellName': {
width: '100%'
}
}),
onRenderHeader: () => {
return <div style={{ height: 42, lineHeight: 1, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div>
<div style={{ marginRight: 5 }}>Name</div>
<div style={{ marginTop: 2, fontSize: '.85em', fontWeight: 400 }}>test</div>
</div>

<TooltipHost content="This is custom tooltip content">
<Icon iconName='Info' />
</TooltipHost>
</div>
}
// onRenderHeader: () => {
// return <div style={{ height: 42, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
// <div>
// <div style={{ marginRight: 5 }}>Name</div>
// <div style={{ fontSize: '.85em', lineHeight: 1, fontWeight: 400, position: 'absolute', bottom: 2 }}>test</div>
// </div>

// <TooltipHost content="This is custom tooltip content">
// <Icon iconName='Info' />
// </TooltipHost>
// </div>
// }
},
{
key: 'age',
Expand Down
3 changes: 2 additions & 1 deletion src/libs/editablegrid/editablegrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1350,11 +1350,12 @@ const EditableGrid = (props: Props) => {
className: `${column.className ? column.className : ''}`,
headerClassName: `${colHeaderClassName} ${column.headerClassName}`,
styles: column.styles,
ariaLabel: column.text,
ariaLabel: column.ariaLabel ? column.ariaLabel : column.text,
fieldName: column.key,
isResizable: true,
minWidth: column.minWidth,
maxWidth: column.maxWidth,
onRenderHeader: column.onRenderHeader,
onColumnContextMenu: !column.disableSort && !(isGridInEdit || editMode) ? (col, ev) => onColumnContextMenu(col) : undefined,
onColumnClick: !(isGridInEdit || editMode) && (isDataTypeSupportedForFilter && column.applyColumnFilter && props.enableColumnFilters) ? (ev, col) => onColumnClick(ev, col, index) : undefined,
//data: item.dataType,
Expand Down

0 comments on commit abd630d

Please sign in to comment.