直接上代码
public function tryui(){
$grid = new Grid(new AdminTest());
//设置字段
$grid->column('id', 'id')->width(80);
$grid->column('test', 'test')->width(80);
$grid->column('test1', 'test1')->width(80);
$grid->column('test2', 'test2')->width(80);
$grid->dataUrl("/index/tryui");
//toolbar设置
$grid->toolbars(function (Grid\Toolbars $toolbars) {
$toolbars->createButton()->content("添加新");
});
//action设置
$grid->actions(function (Grid\Actions $actions) {
$actions->editAction()->requestMethod("put");
$key = $actions->getRow()["id"];
$actions->add(Grid\Actions\ActionButton::make("操作:$key")->handler(Grid\Actions\ActionButton::HANDLER_ROUTE)->uri("index/tryui_create/".$key));
});
return $grid;
}
这个框架走的是restful的接口模式,你可以设置删除或修改按钮请求方式,或者直接自己新增一个操作绑定到指定连接。