Skip to content

Commit

Permalink
Merge pull request #1192 from milanholemans/ListView-rowstyle
Browse files Browse the repository at this point in the history
Add custom row rendering
  • Loading branch information
joelfmrodrigues committed Apr 29, 2022
2 parents 0915b0a + 6c17a0a commit 6587655
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/documentation/docs/controls/ListView.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The ListView control can be configured with the following properties:
| dragDropFiles | boolean | no | Specify the drag and drop files area option. Default false. |
| onDrop | file | no | Event handler returns files from drag and drop. |
| stickyHeader | boolean | no | Specifies if the header of the `ListView`, including search box, is sticky |
| onRenderRow | (props: IDetailsRowProps) => JSX.Element \| null | no | Callback to override the default row rendering. |
| sortItems | (items: any[], columnName: string, descending: boolean) => any[] | no | Custom sorting function to handle sorting by column |
| className | string | no | Class name to apply additional styles on list view wrapper |
| listClassName | string | no | Class name to apply additional styles on list view |
Expand Down
7 changes: 5 additions & 2 deletions src/controls/listView/IListView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Selection, SelectionMode } from 'office-ui-fabric-react/lib/DetailsList';
import { IColumn, IGroup } from 'office-ui-fabric-react/lib/components/DetailsList';
import { IColumn, IGroup, SelectionMode, IDetailsRowProps } from 'office-ui-fabric-react/lib/components/DetailsList';

export { SelectionMode };

Expand Down Expand Up @@ -68,6 +67,10 @@ export interface IListViewProps {
* Set to false by default
*/
stickyHeader?: boolean;
/**
* Callback to override the default row rendering.
*/
onRenderRow?: (props: IDetailsRowProps) => JSX.Element | null;
/**
* Class name to apply additional styles on list view wrapper
*/
Expand Down
3 changes: 2 additions & 1 deletion src/controls/listView/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
public render(): React.ReactElement<IListViewProps> {
let groupProps: IGroupRenderProps = {};

let { showFilter, filterPlaceHolder, dragDropFiles, stickyHeader, selectionMode, compact, className, listClassName } = this.props;
let { showFilter, filterPlaceHolder, dragDropFiles, stickyHeader, selectionMode, compact, className, listClassName, onRenderRow } = this.props;
let { filterValue, items, columns, groups } = this.state;

// Check if selection mode is single selection,
Expand Down Expand Up @@ -625,6 +625,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
groupProps={groupProps}
className={listClassName}
onRenderDetailsHeader={this._onRenderDetailsHeader}
onRenderRow={onRenderRow}
componentRef={ref => {
if (ref) {
ref.forceUpdate();
Expand Down

0 comments on commit 6587655

Please sign in to comment.