Skip to content

Commit 7049bb4

Browse files
committed
Add custom row rendering
1 parent ffc088a commit 7049bb4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

docs/documentation/docs/controls/ListView.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ The ListView control can be configured with the following properties:
9999
| dragDropFiles | boolean | no | Specify the drag and drop files area option. Default false. |
100100
| onDrop | file | no | Event handler returns files from drag and drop. |
101101
| stickyHeader | boolean | no | Specifies if the header of the `ListView`, including search box, is sticky |
102+
| onRenderRow | (props: IDetailsRowProps) => JSX.Element \| null | no | Callback to override the default row rendering. |
102103
| sortItems | (items: any[], columnName: string, descending: boolean) => any[] | no | Custom sorting function to handle sorting by column |
103104
| className | string | no | Class name to apply additional styles on list view wrapper |
104105
| listClassName | string | no | Class name to apply additional styles on list view |

src/controls/listView/IListView.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { Selection, SelectionMode } from 'office-ui-fabric-react/lib/DetailsList';
2-
import { IColumn, IGroup } from 'office-ui-fabric-react/lib/components/DetailsList';
1+
import {
2+
SelectionMode, IColumn,
3+
IDetailsRowProps, IGroup
4+
} from 'office-ui-fabric-react';
35

46
export { SelectionMode };
57

@@ -68,6 +70,10 @@ export interface IListViewProps {
6870
* Set to false by default
6971
*/
7072
stickyHeader?: boolean;
73+
/**
74+
* Callback to override the default row rendering.
75+
*/
76+
onRenderRow?: (props: IDetailsRowProps) => JSX.Element | null;
7177
/**
7278
* Class name to apply additional styles on list view wrapper
7379
*/

src/controls/listView/ListView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
580580
public render(): React.ReactElement<IListViewProps> {
581581
let groupProps: IGroupRenderProps = {};
582582

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

586586
// Check if selection mode is single selection,
@@ -625,6 +625,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
625625
groupProps={groupProps}
626626
className={listClassName}
627627
onRenderDetailsHeader={this._onRenderDetailsHeader}
628+
onRenderRow={onRenderRow}
628629
componentRef={ref => {
629630
if (ref) {
630631
ref.forceUpdate();

0 commit comments

Comments
 (0)