Add Index instead of showing id in table #2053
nepaliayush
started this conversation in
Show and tell
Replies: 1 comment
-
Or see #1990 which is a cleaner way to do this |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
// Initialize the row index
protected int $index = 1;
public function columns(): array
{
return [
//this display index instead of id
Column::make("S.No")
->label(function ($row, Column $column) {
// Return and increment the index for each row
return $this->index++;
}),
//hide the id
Column::make("Id", "id")
->hideIf(true)
->sortable(),
];
}
Beta Was this translation helpful? Give feedback.
All reactions