Skip to content

Commit 9c97193

Browse files
Added field width to ListView
Added a feature that allows users to choose a field width as a prop on the ListView react control
1 parent 5cf8856 commit 9c97193

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/controls/listView/IListView.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export interface IListViewProps {
4747
* Specify the placeholder for the filter text box. Default 'Search'
4848
*/
4949
filterPlaceHolder?: string;
50+
/**
51+
* Specify if the filter width in % 0 - 100.
52+
*/
53+
filterWidth?: number;
5054
/**
5155
* Specify if the filter text box should be rendered.
5256
*/

src/controls/listView/ListView.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
500500
public render(): React.ReactElement<IListViewProps> {
501501
let groupProps: IGroupRenderProps = {};
502502

503-
let { showFilter, filterPlaceHolder } = this.props;
503+
let { showFilter, filterPlaceHolder, filterWidth } = this.props;
504504
let { filterValue, items } = this.state;
505505

506506
// Check if selection mode is single selection,
@@ -517,7 +517,11 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
517517
return (
518518
<div>
519519
{
520-
showFilter && <TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
520+
showFilter &&
521+
// Add div to control the width of the filter for the list view dynamically allowing users to enter a number 0-100 % to alter the field width
522+
<div style={{width:`${filterWidth}%`}}>
523+
<TextField placeholder={filterPlaceHolder || strings.ListViewFilterLabel} onChanged={this._updateFilterValue} value={filterValue}/>
524+
</div>
521525
}
522526
<DetailsList
523527
key="ListViewControl"

0 commit comments

Comments
 (0)