Yii框架zii.widgets.grid自定义按钮
2016-01-19 16:39
477 查看
案例1:
<?php $this->widget('zii.widgets.grid.CGridView', array( 'id'=>'xx-xx-grid', 'dataProvider'=>$model->search(), 'filter'=>$model, 'pager'=>array( 'class'=>'CLinkPager', 'nextPageLabel'=>'下一页', 'prevPageLabel'=>'上一页', 'header'=>'', ), 'summaryText'=>'显示{start}-{end}条.共{count}条记录,当前第{page}页', 'columns'=>array( array( 'name'=>'id', 'htmlOptions'=>array('width'=>'25'), 'sortable'=>false, ), array( 'class'=>'CButtonColumn', 'template'=>'{view} {update}', 'viewButtonOptions'=>array('title'=>'查看'), 'updateButtonOptions'=>array('title'=>'修改'), ), array( 'class'=>'CButtonColumn', 'header'=>'首页展示', 'template'=>'{add} {del}', 'buttons'=>array( 'add' => array( 'label'=>'展示', // text label of the button 'url'=>'Yii::app()->controller->createUrl("focus/create",array("id"=>$data->primaryKey,"type"=>1))', // a PHP expression for generating the URL of the button 'imageUrl'=>'http://s.maylou.com/common/images/ysh.jpg', // image URL of the button. If not set or false, a text link is used 'options'=>array('style'=>'cursor:pointer;'), // HTML options for the button tag 'click'=>$click, // a JS function to be invoked when the button is clicked 'visible'=>'SiteRecommend::isItemInTypeAndId(1, $data->id)?false:true', ), 'del' => array( 'label'=>'取消展示', // text label of the button 'url'=>'Yii::app()->controller->createUrl("focus/delete",array("id"=>$data->primaryKey,"type"=>1))', // a PHP expression for generating the URL of the button 'imageUrl'=>'http://s.maylou.com/common/images/yzhu.jpg', // image URL of the button. If not set or false, a text link is used 'options'=>array('style'=>'cursor:pointer;'), // HTML options for the button tag 'click'=>$click, // a JS function to be invoked when the button is clicked 'visible'=>'SiteRecommend::isItemInTypeAndId(1, $data->id)?true:false', ) ), ), ), )); ?>
案例2:
<?php $this->widget('zii.widgets.grid.CGridView', array( 'id' => 'pages-grid', 'dataProvider' => $dataProvider, 'itemsCssClass' => 'table', 'cssFile' => 'css/thead.css', //'template'=>'{pager}{summary}{items}{pager}', //分页显示所有列的内容 'pager'=>array( 'maxButtonCount'=>'7' //最多显示几个分页页码 ), //显示指定列的内容 'columns' => array( array( 'class'=>'CCheckBoxColumn', 'id'=>'id', 'checked'=>'$data->id==xx' //编辑选中项 ), 'id', 'title', array( 'name' => 'status', 'value' => 'Pages::model()->status($data->id)', ), array( 'name' => 'pushtime', 'value' => 'date("Y-m-d", $data->pushtime)', ), array( 'class' => 'CLinkColumn', 'label' => '相册', //链接显示字样 'urlExpression' => 'Yii::app()->createURL("admin/Album/admin", array("id"=>$data->id))', ), array( 'class' => 'CButtonColumn', 'buttons'=>array('update'=>array( 'url'=>'Yii::app()->createURL("admin/product/update", array("id" =>$data->id, "status"=>"'.$status.'"))' )), //这里可以修改update的表现形式 'deleteConfirmation'=>'确定删除这条数据吗?', //删除提示 'template' => '{update}{delete}' ), ), )); ?>
文章来源:http://currentbottle.blog.163.com/blog/static/1942941282013219435496/
http://blog.sina.com.cn/s/blog_7522019b010153f3.html
相关文章推荐
- PHP PDO数据对象
- (转)在WAMPSERVER下增加多版本的PHP(PHP5.3,PHP5.4,PHP5.5)支持
- php 字符串
- PHP和JAVA双语言重构项目
- 十天学习PHP之第三天
- PHP数组
- PHP基本语法
- PHP的错误和异常处理
- php 全局变量global的作用域
- PHP:( && )逻辑与运算符使用说明
- PHP SQL数据库
- php的socket通信
- composer 安装yii2高级模板
- CodeIgniter配置之routes.php用法实例分析
- PhpStorm 浏览器访问php文件时502错误
- ThinkPHP函数详解:M方法
- CodeIgniter配置之config.php用法实例分析
- PHP basename()函数
- php数组相关处理函数(下)
- Laravel之October Themes