ng2-smart-table icon indicating copy to clipboard operation
ng2-smart-table copied to clipboard

Display line number in row?

Open mopinsk opened this issue 8 years ago • 13 comments

Is it possible to display the respective line number in each row?

mopinsk avatar Jun 28 '17 09:06 mopinsk

Hey mopinsk, I have same requirement. Have u got solution for this?

rangababu1461 avatar Dec 29 '17 09:12 rangababu1461

No, unfortunately I don't have a solution for this.

mopinsk avatar Dec 29 '17 11:12 mopinsk

Ok, Thanks for the response

rangababu1461 avatar Jan 01 '18 10:01 rangababu1461

Hey mopinsk, have you found a solution yet?

bobweeman avatar Jul 22 '18 17:07 bobweeman

I didn't look into this further, so no, I don't have a solution.

mopinsk avatar Jul 26 '18 08:07 mopinsk

Hi, Have you got solution for this problem?

amir1369x avatar Oct 23 '18 16:10 amir1369x

Hi This is my code when setting config of smart table in typescript use it => valuePrepareFunction(row) row object has "index" property use like below particular code you will see it

> columns: {
>         idx: {
>             title : "INDEX",
>             type : "text",
>             filter:false,
>             valuePrepareFunction:(row) =>{
>               //   console.log(row); 
>               //   console.log(row.index);
>               return `${row.index}`;
>             }
>         },

dovewing avatar Nov 08 '18 06:11 dovewing

Hi This is my code when setting config of smart table in typescript use it => valuePrepareFunction(row) row object has "index" property use like below particular code you will see it

> columns: {
>         idx: {
>             title : "INDEX",
>             type : "text",
>             filter:false,
>             valuePrepareFunction:(row) =>{
>               //   console.log(row); 
>               //   console.log(row.index);
>               return `${row.index}`;
>             }
>         },

it not work for me

Svathna avatar Sep 03 '19 05:09 Svathna

row.index is only good for first page see a working solution

export interface IPaging { page:number; perPage:number; }

valuePrepareFunction : (value,row,cell)=>{ const paging:IPaging = this.source.getPaging(); const ret = (paging.page-1) * paging.perPage + cell.row.index+1; return ret; }

hope4555 avatar Oct 25 '19 20:10 hope4555

Hi This is my code when setting config of smart table in typescript use it => valuePrepareFunction(row) row object has "index" property use like below particular code you will see it

> columns: {
>         idx: {
>             title : "INDEX",
>             type : "text",
>             filter:false,
>             valuePrepareFunction:(row) =>{
>               //   console.log(row); 
>               //   console.log(row.index);
>               return `${row.index}`;
>             }
>         },

The first parameter of valuePrepareFunction contains the value of the cell. Hence, it doesn't contain any index.

smrgrg avatar Dec 09 '19 23:12 smrgrg

function* generateNumbers () {
  let index = 1;
  while (true) {
    yield index++;
  }
}

const tableId = generateNumbers();

columns: {
  id: {
    title: 'ID',
    type: 'number',
    valuePrepareFunction: () => {
      return tableId.next().value;
    },
  },
}

ng-alynasser avatar Jan 04 '20 11:01 ng-alynasser

Hi This is my code when setting config of smart table in typescript use it => valuePrepareFunction(row) row object has "index" property use like below particular code you will see it

> columns: {
>         idx: {
>             title : "INDEX",
>             type : "text",
>             filter:false,
>             valuePrepareFunction:(row) =>{
>               //   console.log(row); 
>               //   console.log(row.index);
>               return `${row.index}`;
>             }
>         },

it not work for me

if you have paging , the second page will show incorrect value

hope4555 avatar Jan 04 '20 20:01 hope4555

This work fine for me...

columns: {
 index: {
   title: "Item",
   type: "text",
   width: "100px",
   valuePrepareFunction: (value, row, cell) => {
    return cell.row.index + 1;
   },
  },
}

image

jdgabriel avatar Aug 10 '21 14:08 jdgabriel