Skip to content

Commit 55cbc18

Browse files
Allow default selection of items
1 parent 44390f7 commit 55cbc18

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/controls/listView/ListView.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,28 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
4646
* @param prevState
4747
*/
4848
public componentDidUpdate(prevProps: IListViewProps, prevState: IListViewState): void {
49+
// select default items
50+
this._setSelectedItems();
51+
4952
if (!isEqual(prevProps, this.props)) {
5053
this._processProperties();
5154
}
5255
}
5356

57+
/**
58+
* Select all the items that should be selected by default
59+
*/
60+
private _setSelectedItems(): void {
61+
if (this.props.items && this.props.items.length > 0) {
62+
for (const item of this.props.selectIems) {
63+
const index: number = findIndex(this.props.items, element => isEqual(element, item));
64+
if (index > -1) {
65+
this._selection.setIndexSelected(index, true, false);
66+
}
67+
}
68+
}
69+
}
70+
5471
/**
5572
* Specify result grouping for the list rendering
5673
* @param items

0 commit comments

Comments
 (0)