【发布时间】:2021-09-03 00:14:22
【问题描述】:
我正在处理 Material-UI 表,例如下面的basic table,但我在开头添加了一个 id 列。
假设我在我的 React 应用程序中的路径 localhost:3000/basic-table 有这个基本表格示例,我如何使用下面的代码并将 <tableCell>{row.id}</tableCell> 变成 <a href link>,这将允许用户点击这个 @987654326 @column 然后向用户展示一个新屏幕,我可以在哪里获取这个 id 并显示更多关于它的数据?
我还需要一种返回主页报告的方法,即父页面。
我想要实现的基本上是来自主父报告,用户可以单击行 ID,然后会根据该 ID 向用户显示详细报告,即像向下钻取报告一样。
从文档中,我找不到任何可以实现此目的的示例,因为不确定如何添加列链接。
谁能帮忙或者给我举个例子。
{rows.map((row) => (
<TableRow key={row.id}>
<TableCell component="th" scope="row">
{row.id}
</TableCell>
<TableCell align="right">{row.name}</TableCell>
<TableCell align="right">{row.calories}</TableCell>
<TableCell align="right">{row.fat}</TableCell>
<TableCell align="right">{row.carbs}</TableCell>
<TableCell align="right">{row.protein}</TableCell>
</TableRow>
))}
【问题讨论】:
-
对于其他人来说,下面的答案很好,但我最终使用了下面的代码
/elsewhere/${row.id} } style={{ textDecoration: 'underline', color: 'black' }} > {value} 达到我的要求。这是来自stackoverflow.com/questions/50691049/…
标签: reactjs material-ui report material-table drilldown