I want to catch the event when click in a row field of a DetailsList in Webpart. My code looks like :
return (
<div>
<div>
<div className="ms-Grid">
<div className="ms-Grid-row">
<DetailsList
items={_items}
columns={this.state.columns}
setKey='set'
onRenderItemColumn={this._renderItemColumn}
onColumnHeaderClick={this._onColumnClick.bind(this)}
onItemInvoked={(item, index) => alert(`Item ${item.name} at index ${index} has been invoked.`)}
onColumnHeaderContextMenu={(column, ev) => console.log(`column ${column.key} contextmenu opened.`)} />
</div>
</div>
</div>
</div>
);
.....
private _renderItemColumn(item, index, column) {
let fieldContent = item[column.fieldName];
switch (column.key) {
case 'file':
return <Link onClick={this._onColumnClickView.bind(item)} id={item['id']}>{fieldContent}</Link>
default:
return <span >{fieldContent}</span>;
}
}
....
private _onColumnClickView(ev, column) {
console.log(column);
// your code here
}
But it doesn't work. The Link doesn't display. I changed the code to:
private _renderItemColumn(item, index, column) {
let fieldContent = item[column.fieldName];
switch (column.key) {
case 'file':
return <Link onClick={this._onColumnClickView.bind(this)} id={item['id']}>{fieldContent}</Link>
default:
return <span >{fieldContent}</span>;
}
}
But nothing changes. Any help will be greatly appreciated