material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Any way to get Serial Numbers in the data table ?

Open Prasad-YS opened this issue 7 years ago • 18 comments

In Addition to the data that I'm getting I want show the Serial Number in 1st Column ? Is this possible ?

Prasad-YS avatar Jan 31 '19 07:01 Prasad-YS

Hi @Prasad-YS,

I can do this for next releases.

mbrn avatar Jan 31 '19 10:01 mbrn

@Prasad-YS

You do this with current version. We already have an tableData.id field on every row of data. Just add a new column like this: columns: { title: '#', field: 'tableData.id' }

mbrn avatar Jan 31 '19 18:01 mbrn

title: '#', field: 'tableData.id'

Sorry, Didn't get any number, just got a blank column

Prasad-YS avatar Feb 01 '19 04:02 Prasad-YS

Which version of material-table do you use?

mbrn avatar Feb 01 '19 04:02 mbrn

I'm using 1.13.0

Prasad-YS avatar Feb 04 '19 06:02 Prasad-YS

Can you share your material-table usage code

mbrn avatar Feb 04 '19 06:02 mbrn

Updated to new version, Got the serial number now, Thanks lot for your support

Prasad-YS avatar Feb 04 '19 06:02 Prasad-YS

Is it possible to make the tableData.id start from 1 instead of 0?

SourishMukherjee avatar Jun 26 '20 18:06 SourishMukherjee

@mbrn Is it possible to make the tableData.id start from 1 instead of 0??

ahsan-baloch avatar Sep 18 '20 08:09 ahsan-baloch

@ahsan-baloch just do tableData.id + 1

abdulhadi1995 avatar Sep 18 '20 10:09 abdulhadi1995

@ahsan-baloch { title: '#', field: 'tableData.id', render:rowData => { return( <p>{rowData.tableData.id+1}</p> ) } }

abdulhadi1995 avatar Sep 18 '20 10:09 abdulhadi1995

@ahsan-baloch { title: '#', field: 'tableData.id', render:rowData => { return( <p>{rowData.tableData.id+1}</p> ) } }

but with thet when exported to pdf or csv the count shows from 0 not 1

ahsan-baloch avatar Sep 18 '20 11:09 ahsan-baloch

@ahsan-baloch just do tableData.id + 1

render: (rowData) => rowData.tableData.id + 1 this worked for me but still when exporting it into csv or pdf count starts from 0 not 1

ahsan-baloch avatar Sep 18 '20 11:09 ahsan-baloch

@ahsan-baloch you could first customize the data before it begins writing to CSV. you'll have to look around for that unfortunately coz i used another package as I didn't know material table supported exporting to CSV.

abdulhadi1995 avatar Sep 18 '20 11:09 abdulhadi1995

@ahsan-baloch you could first customize the data before it begins writing to CSV. you'll have to look around for that unfortunately coz i used another package as I didn't know material table supported exporting to CSV.

ahh okay thanks for the help

ahsan-baloch avatar Sep 18 '20 11:09 ahsan-baloch

@ahsan-baloch just do tableData.id + 1

render: (rowData) => rowData.tableData.id + 1 this worked for me but still when exporting it into csv or pdf count starts from 0 not 1

this works for me too but it doesn't update with search and sort. Any solution for it?

iraxaxaidi avatar Feb 17 '21 14:02 iraxaxaidi

columns={[ { title: '#', field: 'tableData.id', render:rowData => { return(

{rowData.tableData.id+1}

) } },
{ title: 'UserName', field: 'userName' }, { title: 'Email ID', field: 'userEmail' }, { title: 'Name', field: 'firstName' }, { title: 'Mobile No', field: 'userMobileNO' } ]}

vikram-java avatar Aug 21 '21 07:08 vikram-java

columns = [ { title: '#, field: 'tableData.id', render:rowData => rowData.tableData.id+1} , { title: 'First Name', field: 'FirstName', },
{ title: 'Last Name', field: 'LastName', }

sarath-kumar-gs avatar Dec 16 '21 07:12 sarath-kumar-gs