ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 表头(必须) > 图片演示: ![](https://img.kancloud.cn/11/2d/112d488aaf8e24281efe5759471776dd_1620x691.png) > 说明: 设置表头。 方法:`cols($callable)` * 参数 **callable** (必须),例: ```php cols(function($state){ $cols=[ 'id'=>['type'=>'checkbox'], 'name'=>['title'=>'姓名'], 'age'=>['title'=>'年龄','align'=>'center','hide'=>'mobile'], 'create_time'=>['title'=>'添加时间', 'align'=>'center','hide'=>'mobile_hide','templet'=>'datetime'], 'action'=>[ 'title'=>'操作', 'templet'=>'action', 'options'=>[ 'edit'=>['type'=>'open_popup','title'=>'详情','icon'=>'layui-icon layui-icon-survey','url'=>url('edit')] ] ] ]; switch($state){ case 11: $cols['action']['options']+=[ 22=>['type'=>'async_event','title'=>'移入回收站','dropdown'=>true], ]; break; case 22: $cols['action']['options']+=[ 11=>['type'=>'async_event','title'=>'还原','dropdown'=>true], 99=>['type'=>'async_event','title'=>'永久删除','dropdown'=>true] ]; break; } return $cols; }); ``` > 表头配置详见:[表头配置](https://www.kancloud.cn/worklz/yunj_admin_universal/2024526) > 示例: 设置`正常(11)`状态表头为`中文姓名`+`英文姓名`+`年龄`+`添加时间`+`更新时间`+`操作(详情、移入回收站)`;`回收站(22)`状态表头为`中文姓名`+`英文姓名`+`年龄`+`添加时间`+`更新时间`+`操作(详情、还原、永久删除)` * 方法如下: ~~~ $builder=YT('general_example')->cols(function($state){ $cols=[ 'id'=>['type'=>'checkbox'], 'name_cn'=>['title'=>'中文姓名'], 'name_en'=>['title'=>'英文姓名'], 'age'=>['title'=>'年龄','align'=>'center','hide'=>'mobile'], 'create_time'=>['title'=>'添加时间', 'align'=>'center','hide'=>'mobile_hide','templet'=>'datetime'], 'update_time'=>['title'=>'更新时间', 'align'=>'center','hide'=>'yes','templet'=>'datetime'], 'action'=>[ 'title'=>'操作', 'templet'=>'action', 'options'=>[ 'edit'=>['type'=>'open_popup','title'=>'详情','icon'=>'layui-icon layui-icon-survey','url'=>url('edit')] ] ] ]; switch($state){ case 11: $cols['action']['options']+=[ 22=>['type'=>'async_event','title'=>'移入回收站','dropdown'=>true], ]; break; case 22: $cols['action']['options']+=[ 11=>['type'=>'async_event','title'=>'还原','dropdown'=>true], 99=>['type'=>'async_event','title'=>'永久删除','dropdown'=>true] ]; break; } return $cols; }) ~~~