$grid ->column("index",'序號'); $grid->model()->collection(function (Collection $collection)use($grid){ $page = request('page')?:1; $startIndex = (($page-1)*$grid->perPage); foreach ($collection as $key=>$collect){ $collect->index =$startIndex+$key+1; } return $collection; });
只能這樣寫了,暫時不知道有啥更好的方法;