如何获取 AgGrid 中的行索引?

How to get index of rows in AgGrid?

我想在 AgGrid 中获取行的索引。我该怎么做?

{
  headerName: 'row',
  align: 'center' as const,
  dataIndex: 'id',
  key: 'id',
  width: 20,
  valueGetter: column => column.rowIndex + 1,
},

根据 Ag-grid 文档:

你可以试试这个:

{
      headerName: 'row',
      align: 'center' as const,
      dataIndex: 'id',
      key: 'id',
      width: 20,
      valueGetter: params => params.node.rowIndex + 1,
},