目前在reactjs中使用grid.js创建我的数据表。
这是我的代码
<Grid
data={data.filter(e => e.status != 0)}
columns={[
{
id: 'url',
name: 'url',
hidden: true
}, {
id: 'id',
name: '#',
formatter: (cell) => _(this.showIndexNo()) //<-- where i do the function to display row index number
}, {
id: 'name',
name: 'Name'
}, {
id: 'smgk_name',
name: 'SM Name',
formatter: (cell, row) => _(this.showSmlink(row.cells[0].data, row.cells[3].data))
}, {
id: 'email',
name: 'Email',
// formatter: (cell) => _(moment(cell).format(MOMENT_FORMAT))
},
{
id: 'id',
name: 'Actions',
formatter: (cell) => _(this.showButton(cell))
//(cell) => `Name: ${cell}`
}
]}
search={true}
sort={true}
/>
我想在网格js中显示行索引/自动递增。我应该如何编辑此代码?
showIndexNo() {
const { subscriberData } = this.state;
let a = [];
return (subscriberData.filter(e => e.status != 0).map((item, i) => i ) ) }
我得到这个结果:
我不能将ID用作行索引,因为当我删除一个详细信息时,Id仍将存在,只有状态将更改为Deleted(这不会显示在网格中),因此我需要行索引。非常感谢任何帮助
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句