Skip to content

Commit 6587655

Browse files
Merge pull request #1192 from milanholemans/ListView-rowstyle
Add custom row rendering
2 parents 0915b0a + 6c17a0a commit 6587655

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
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 { IColumn, IGroup, SelectionMode, IDetailsRowProps } from 'office-ui-fabric-react/lib/components/DetailsList';
32

43
export { SelectionMode };
54

@@ -68,6 +67,10 @@ export interface IListViewProps {
6867
* Set to false by default
6968
*/
7069
stickyHeader?: boolean;
70+
/**
71+
* Callback to override the default row rendering.
72+
*/
73+
onRenderRow?: (props: IDetailsRowProps) => JSX.Element | null;
7174
/**
7275
* Class name to apply additional styles on list view wrapper
7376
*/

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)