就直接显示
一开始我也很着急,弄了半天还是不行,然后重写还是有问题
最后发现底层代码排序是按照id排序的orderBy('id', 'asc') ,我们直接重新设置一个字段排序即可 $grid->model()->orderBy('idx','desc');只要是表中有的字段即可
- public function grid()
- {
- // dd(Article::with(['author','type'])->offset(1)->limit(10)->get()->toArray());
-
- $grid = new Grid(new Article());
- $grid->column('idx','id');
- $grid->model()->orderBy('idx','desc');
-
- $grid->column('title','标题');
- $grid->column('aaatype.name','类型');
- $grid->column('content','内容');
- $grid->column('aaaauthor.name','作者');
- $grid->column('created_at','日期');
-
- return $grid;
-
- }
修改完后我重新试了一下
结果OK;