Skip to content

Commit aedf228

Browse files
delect default items by index
1 parent 449c30d commit aedf228

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/controls/listView/IListView.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ export interface IListViewProps {
1818
* The items to render.
1919
*/
2020
items: any[];
21-
/**
22-
* The items to select by default.
23-
*/
24-
selectIems?: any[];
2521
/**
2622
* The fields you want to view in your list view
2723
*/
@@ -44,6 +40,10 @@ export interface IListViewProps {
4440
* Selection event that passes the selected item(s)
4541
*/
4642
selection?: (items: any[]) => void;
43+
/**
44+
* The index if items to be select by default.
45+
*/
46+
defaultSelection?: number[];
4747
}
4848

4949
export interface IListViewState {

src/controls/listView/ListView.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ export class ListView extends React.Component<IListViewProps, IListViewState> {
5858
* Select all the items that should be selected by default
5959
*/
6060
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));
61+
if (this.props.items && this.props.items.length > 0 && this.props.defaultSelection && this.props.defaultSelection.length > 0) {
62+
for (const index of this.props.defaultSelection) {
6463
if (index > -1) {
6564
this._selection.setIndexSelected(index, true, false);
6665
}

0 commit comments

Comments
 (0)