I am trying to add a serial to the grid but failed.
protected function grid()
{
$grid = new Grid(new TransactionLedger);
$grid->rows(function ($row){
$this->serial = $sl = $row->model()['id'];
if($row->model()['id']%4==3){
$row->style("background-color:#eee");
}
if($row->model()['id']%4==0){
$row->style("background-color:#eee");
}
});
$grid->column('SL')->display(function(){
return $this->serial ;
});
}
It seems that you want to display id field to SL column, why no just use $grid->column('id', 'SL');
@z-song Sorry, $grid->column('id', 'SL'); it's returning the id , but i need the serial number not id. I want to show the serials like :
1
2
3
4
Try this https://github.com/z-song/laravel-admin/issues/1994#issuecomment-386206283
This works, but problems in pagination. When going to the next page it starts from 1 again.
It's working for single page, when I am using pagination it's counting from 1 in the second page.
Could you please give me a suggestion to solve this issue.
Most helpful comment
Try this https://github.com/z-song/laravel-admin/issues/1994#issuecomment-386206283