I am trying to conditionally disable mouse click events on certain rows in a OUIF DetailsList. But I can't seem to get it to work. I tried overriding onRenderRow and setting CheckboxVisibility to none but it was still clickable. Then I tried wrapping a div around it and setting that to disabled. However, div's in React don't seem to have disabled attribute. So can anybody help me out here?
<DetailsList
items={this.state.items}
columns={this.getColumns()}
selection={this.selection}
selectionMode={SelectionMode.multiple}
onRenderRow={this.renderRow.bind(this)}>
</DetailsList>
private renderRow(props: IDetailsRowProps, defaultRender: any){
let state = this.state.items[props.itemIndex].workflowState;
if(state === "disabledState"){
//props.checkboxVisibility = CheckboxVisibility.hidden; <- Not working
// return <div disabled={true}>{defaultRender(props)}</div> <- Not working
return defaultRender(props);
}
else{
return defaultRender(props);
}
}
Solution:
this.selection = new Selection({ canSelectItem: this.canSelectItem.bind(this), onSelectionChanged: this.clickRow.bind(this) });
<DetailsList
items={this.state.items}
columns={this.getColumns()}
selection={this.selection}
selectionMode={SelectionMode.multiple}
onRenderRow={this.renderRow.bind(this)}>
</DetailsList>
private canSelectItem(item: any): boolean {
return item.state !== "disabledState";
}