zanix's avatar
Level 22

Livewire table sequence numbers with pagination

What is the best way to keep track of sequence numbers in the Livewire paginated table?

The first column in my table contains sequence numbers from 1 to "total number of rows" everything was fine with Blade's $loop->iteration but when I introduced pagination on each page that sequence is starting from 1 every time and I don't want that I want to keep track of each row's number.

What would be the best way to achieve this functionality?

Current state

Page 1

| # | First Name |

| 1 | John |

| 2 | Jenny |

| 3 | Mark |

| 4 | Steve |

Page 2

| # | First Name |

| 1 | Bob |

| 2 | Billy |

| 3 | Tiller |

| 4 | Scot |

Desired state

Page 1

| # | First Name |

| 1 | John |

| 2 | Jenny |

| 3 | Mark |

| 4 | Steve |

Page 2

| # | First Name |

| 5 | Bob |

| 6 | Billy |

| 7 | Tiller |

| 8 | Scot |

0 likes
2 replies
Dhruva's avatar
Dhruva
Best Answer
Level 11

You can use this for sequential numbering..

{{ ($users ->currentpage()-1) * $users ->perpage() + $loop->index + 1 }}

2 likes
zanix's avatar
Level 22

Thank you very much that was the solution. 🙌

1 like

Please or to participate in this conversation.