~~~
return TBuilder('table',$this)->setColumns([ // 批量设置数据列
['id', 'ID'],
['title.text', '名称'],//以普通文本编辑
['edit.edit_data|id+title,del', '操作', ['type'=>'btn']]
])
// 添加相关操作按钮
->addListButton([
'type'=> 'edit',
'icon_class'=> 'fa fa-pencil',
])
->addListButton([
'title'=> '查看',
'href_base'=> 'menu/index',
'href_param'=> 'id',
'icon_class'=> 'fa fa-list',
])
->addListButton([
'title'=> '查看2',
'href_base'=> 'menu/index',
'href_param'=> 'pid.id',
'icon_class'=> 'fa fa-list',
])
->addListButton([
'title'=> '查看3',
'href_base'=> array('menu/index',array('date'=>'2017-05-06') ),
'href_param'=> 'pid.id+type+classify_id.cid',
'icon_class'=> 'fa fa-list',
])
->fetch();
~~~
使用addListButton方法添加列表单项元素操作按钮
![](https://box.kancloud.cn/7a8b0f812e280e2b437aa995afecb76e_715x229.png)
### 通过 show_map 参数可以配置依据列表值显隐按钮
~~~
->addListButton([
'title'=> '卸载',
'type'=> 'del',
'show_map'=> ['is_install'=>['eq',1]]
])
->addListButton([
'title'=> '安装',
'href_base'=> 'install',
//'href_param'=> 'pid.id',
'item_class'=> 'btn-system',
'icon_class'=> 'fa fa-wrench',
'show_map'=> ['is_install'=>['eq',0]]
])
~~~
![](https://box.kancloud.cn/4a80ba811d4be888c03f3ee3dc5bf33b_1626x106.png)
~~~
->addListButton([
'title'=> '设置',
'href_base'=> 'config',
'item_class'=> 'btn-info',
'icon_class'=> 'fa fa-cog',
'show_map'=> ['is_install'=>['eq',1],'config'=>['neq',''],]
])
->addListButton([
'title'=> '禁用',
'href_base'=> 'disable',
'item_class'=> 'btn-warning ajax-get',
'icon_class'=> 'fa fa-cog',
'show_map'=> ['status'=>['eq',1],'is_install'=>['eq',1]]
])
->addListButton([
'title'=> '启用',
'href_base'=> 'enable',
'item_class'=> 'btn-success ajax-get',
'icon_class'=> 'fa fa-cog',
'show_map'=> ['status'=>['eq',0],'is_install'=>['eq',1]]
])
->addListButton([
'title'=> '卸载',
'type'=> 'del',
'item_class'=> 'btn-danger ajax-get',
'href_base'=> 'uninstall',
'show_map'=> ['is_install'=>['eq',1]]
])
->addListButton([
'title'=> '安装',
'href_base'=> 'install',
//'href_param'=> 'pid.id',
'item_class'=> 'btn-system ajax-get',
'icon_class'=> 'fa fa-wrench',
'show_map'=> ['is_install'=>['eq',0]]
])
~~~
![](https://box.kancloud.cn/dcc1e11097546fa7d888c1fed9430ef4_1600x227.png)
支持:eq、neq、gt、egt、lt、elt、in、notin、between、notbetween
### 通过href_base及href_param可以生成多种形式的url
href_base
* 为数组时,第一个为基础url,第二个为固定参数数组。
* 为字符串时,仅为基础url
~~~
->addListButton([
'title'=> '全局设置',
'icon_class'=> 'fa fa-file-text-o',
'href_base'=> array('builderProject',array('step'=>'global_settings') ),
//'popup'=> true
])
~~~
href_param
* 通过+号可以添加多个字段到数组中
* 通过.给字段设置别名(请求参数字段名.列表数据字段),如果没有.则参数字段和数据字段使用同一个字段名
### popup 配置模态框打开链接
* 当popup设置为true时链接以模态框形式打开,iframe方式访问