gpt4 book ai didi

office-ui-fabric - 如何在 DetailsList 组件中使整行可点击? (office-ui-fabric)

转载 作者:行者123 更新时间:2023-12-04 01:44:49 26 4
gpt4 key购买 nike

我一直在使用 DetailsList 组件,但还没有找到使整行可点击的方法 - 是否有示例代码片段或有关如何实现这一点的指针?

https://developer.microsoft.com/en-us/fabric#/components/detailslist

最佳答案

覆盖 onRenderRow 对我有用。

const _columns: IColumn[] = [
{
key: 'name',
name: 'Name',
fieldName: 'name',
minWidth: 100,
maxWidth: 200,
isResizable: true
},
{
key: 'value',
name: 'Value',
fieldName: 'value',
minWidth: 100,
maxWidth: 200,
isResizable: true,
}
];

const _items = Array.apply(null, Array(10)).map((_: any, num: number) => ({
key: num.toString(),
name: `Item ${num.toString()}`,
value: num.toString()
}));

class Content extends React.Component {
private _renderRow(props: Fabric.IDetailsRowProps, defaultRender: any): JSX.Element {
return (
<Fabric.DetailsRow {...props} onClick={() => alert('click')}/>
);
}

public render() {
return (
<Fabric.Fabric>
<Fabric.DetailsList
items={ _items }
columns={ _columns.concat(..._columns, ..._columns, ..._columns) }
onRenderRow={this._renderRow}
/>
</Fabric.Fabric>
);
}
}

ReactDOM.render(
<Content />,
document.getElementById('content')
);

关于office-ui-fabric - 如何在 DetailsList 组件中使整行可点击? (office-ui-fabric),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55733551/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com