Yii1自定义 CGridView 中的操作按钮中 CButtonColumn 选项
Yii可以使用CButtonColumn自定义按钮及列样式。
效果展示
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'knowledge-auth-list-grid',
'dataProvider'=>$model->search(),
//'filter'=>$model,
'columns'=>array(
array(
'name' => 'id',
'type' => 'raw',
'value' => 'CHtml::link($data->id, array("knowledgeAuthList/view", "id"=>$data->id))'
),
'auth_name',
'operator',
array(
'name' =>'create_time',
'headerHtmlOptions'=>array(
'width'=>'',
),
),
array(
'header'=>'操作',
'class'=>'CButtonColumn',
),
),
)); ?>

//控制操作列按钮展示代码
array(
'header'=>'操作',
'class'=>'CButtonColumn',
'headerHtmlOptions'=>array(
'width'=>'',
),
'template'=>'{view} {update} {delete}', //默认显示的三个按钮,要去掉某个按钮,删除相应项即可
),
//增加自定义
自定义一个按钮:
比如添加一个额外的功能按钮'设定',点击可跳转到指定id的设定页。
首先,在template中加入新的标签:'template'=>'{set} {view} {update} {delete}',
然后,定义buttons,加入recharge按钮的定义: array(
'header' => '操作',
'class'=>'CButtonColumn',
'headerHtmlOptions' => array('width'=>''),
'htmlOptions' => array('align'=>'center'),
'template'=>'{set} {delete}',
'buttons'=>array(
'set' => array(
'label'=>'设定',
'imageUrl'=>Yii::app()->request->baseUrl.'/images/set.png',
'url'=>'Yii::app()->createUrl("auth/set", array("id"=>$data->id))',
),
),
),
//单个按钮的属性: 'buttonID' => array
(
'label'=>'...', //显示为图片的title,鼠标放上去以后显示的文字
'url'=>'...', //超链接的地址
'imageUrl'=>'...', //按钮的图片src
'options'=>array(), //按钮的html属性,譬如width,height,style,class等等
'click'=>'...', //点击的JS动作,需放在function(){}中
'visible'=>'...', //显示该按钮的条件,如 'visible'=>'$data->score > 0',
)
//修改删除按钮的提示: array
(
'class'=>'CButtonColumn',
'deleteConfirmation'=>"js:'Record with ID '+$(this).parent().parent().children(':first-child').text()+' will be deleted! Continue?'",
),
Yii1自定义 CGridView 中的操作按钮中 CButtonColumn 选项的更多相关文章
- PowerShell_零基础自学课程_5_自定义PowerShell环境及Powershell中的基本概念
PowerShell_零基础自学课程_5_自定义PowerShell环境及Powershell中的基本概念 据我个人所知,windows下的cmd shell除了能够通过修改系统参数来对其中的环境变量 ...
- 在.Net MVC中自定义ValidationAttribute标签对Model中的属性做验证
写一个继承与ValidationAttribute类的自定义的验证方法 MVC中传递数据时,大多数都会用Model承载数据,并且在传到控制器后,对Model进行一系列的验证. 我平时经常使用的判断方法 ...
- jsp 自定义标签解决jsp页面中int时间戳的时间格式化问题
jsp 自定义标签解决jsp页面中int时间戳的时间格式化问题 之前在项目中根据需求,需要自定义标签,经过查询w3c文档,自己也踩了一些坑,特此记录自定义标签的步骤,下面就以我之前的一个例子中的定义一 ...
- ztree树形图自定义图标在jeecg框架中不显示
有时候工作遇到问题,就会硬着头皮去解决,今天给大家说一个ztree树形图自定义图标在jeecg框架中不显示的解决方法 对于这个问题,官方观法说法是在节点元素中加入icon的字段,然后后跟图标的url, ...
- 【spring boot】在自定义拦截器中从request中获取json字符串
又这样的需求,需要在自定义的拦截器中获取request中的数据,想获取到的是JSON字符串 那需要在拦截器中写这样一个方法 public static String getOpenApiRequest ...
- 查询SQLServer2005中某个数据库中的表结构、索引、视图、存储过程、触发器以及自定义函数
查询SQLServer2005中某个数据库中的表结构.索引.视图.存储过程.触发器以及自定义函数 2013-03-11 09:05:06| 分类: SQL SERVER|举报|字号 订阅 ( ...
- android 自定义空间 组合控件中 TextView 不支持drawableLeft属性
android 自定义空间 组合控件中 TextView 不支持drawableLeft属性.会报错Caused by: android.view.InflateException: Binary X ...
- 在VS2005中设置WPF中自定义按钮的事件
原文:在VS2005中设置WPF中自定义按钮的事件 上篇讲了如何在Blend中绘制圆角矩形(http://blog.csdn.net/johnsuna/archive/2007/08/13/17407 ...
- Springboot中使用自定义参数注解获取 token 中用户数据
使用自定义参数注解获取 token 中User数据 使用背景 在springboot项目开发中需要从token中获取用户信息时通常的方式要经历几个步骤 拦截器中截获token TokenUtil工具类 ...
随机推荐
- ubuntu14.04 terminator字体挤在一起问题
字体挤在一起:在ubuntu下请选择mono后缀的字体就可以了 右键—>首选项—>profile—>general—>字体设置成ubuntu mono 或Free mono
- SimpleDateFormat 出现错误 Call requires API level 24 (current min is 15)
这个故事是这样的 今天写打卡时间的时候需要获取一下当前时间,然后我就写了一个这个 SimpleDateFormat sDF = new SimpleDateFormat("yyyy-MM ...
- Vs code常用插件
Vs code常用插件 1.View In Browser 由于 VSCode 没有提供直接在浏览器中打开文件的内置界面,所以此插件在快捷菜单中添加了在默认浏览器查看文件选项,以及在客户端(Firef ...
- Spring AOP 随记
本周经历各种面试失败后,最后一站张建飞老大的阿里,感觉有着这般年纪不该有的垃圾履历而忧伤中,不过还是要继续加油的,毕竟他说的好,都是经历,无愧初心. 所以为了更加深入理解Spring AOP我又翻起了 ...
- 向comboboxEdit中动态添加数据库中保存的用户自定义单位制的名称
if (radioGroup1.SelectedIndex == 2) { bool _Flag = true; sm.SetLciVisible(lciDelete, _Flag); sm.SetL ...
- ubuntu下安装go环境
1.官网下载go语言安装包 地址:https://studygolang.com/dl 2.服务器上安装go 将下载下来的安装包解压到/usr/local下 tar xf go1.12.1.linux ...
- 初识NLTK
需要用处理英文文本,于是用到python中nltk这个包 f = open(r"D:\Postgraduate\Python\Python爬取美国商标局专利\s_exp.txt") ...
- python 中字符串的格式化
# 字符串格式化name = input("name:")age = int(input("age:"))job = input("job:" ...
- c 语言 随机数选取6个数 一定范围内
种子来源 定时器/****************** 自动筛选种子 dat 目标种子 ************/ #define max 7 //随机生成最大的数为7 #define min 1 / ...
- 关于break,return,和coutiune
public boolean searchStudent(String name,int start,int end) { if(students==null) { return false; } f ...