【问题标题】:How to add ids to material table rows?如何将 ID 添加到材料表行?
【发布时间】:2020-05-28 11:19:47
【问题描述】:

我正在与React-material-table 合作。我想为每一行添加一个自定义 id,然后通过 selenium 将其用于识别元素。我浏览了互联网,但无法获得任何帮助。

这是我正在做的:

 <MaterialTable
          columns={[
            { title: 'Adı', field: 'name' },
            { title: 'Soyadı', field: 'surname' },
            { title: 'Doğum Yılı', field: 'birthYear', type: 'numeric' },
            { title: 'Doğum Yeri', field: 'birthCity', lookup: { 34: 'İstanbul', 63: 'Şanlıurfa' } }
          ]}
          data={[{ name: 'Mehmet', surname: 'Baran', birthYear: 1987, birthCity: 63 }]}
          title="Demo Title"
        />

如何为每一行添加 id?

【问题讨论】:

标签: reactjs material-table


【解决方案1】:

试试这个(docs查看组件下)

<MaterialTable        
    components={{
        Row: props => <MTableBodyRow id="SOME-ROW-ID-HERE" {...props} />
    }}

  // other props

/>

【讨论】:

  • 当我们使用detailPanel时,我们如何将id添加到材料表中每一行的图标'>'?
  • @NehaChaudhary 应该可以使用 icondetailPanel 属性。检查this了解更多详情如果您将此作为新问题提出,您将获得更多详情
  • 如果我们想将 id 添加到我们通过设置 options = {{selection:true}} 获得的材料表中的复选框?有没有办法将 id 设置为我们得到的复选框?另外,对于搜索栏!
猜你喜欢
  • 2019-05-24
  • 1970-01-01
  • 2022-08-05
  • 1970-01-01
  • 2020-06-10
  • 2018-06-26
  • 2020-12-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多