Yii CGridView用法实例详解

前端之家收集整理的这篇文章主要介绍了Yii CGridView用法实例详解前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了Yii CGridView用法分享给大家供大家参考,具体如下:@H_301_1@

CGridView的功能是用来显示的数据列表。它支持排序,分页,和AJAX数据请求。@H_301_1@

CGridView最好使用 ,最好是 。@H_301_1@

简单代码如下:

@H_301_1@
widget('zii.widgets.grid.CGridView',array( 'dataProvider'=>$dataProvider,));

详细示例:

@H_301_1@
widget('zii.widgets.grid.CGridView','columns'=>array( 'title',// display the 'title' attribute 'category.name',// display the 'name' attribute of the 'category' relation 'content:html',// display the 'content' attribute as purified HTML array( // display 'create_time' using an expression 'name'=>'create_time','value'=>'date("M j,Y",$data->create_time)',),array( // display 'author.username' using an expression 'name'=>'authorName','value'=>'$data->author->username',array( // display a column with "view","update" and "delete" buttons 'class'=>'CButtonColumn',));

属性说明:

@H_301_1@

actionPrefix 方法前辍@H_301_1@

afterAjaxUpdate AJAX成功响应后调用的JAVASCRIPT函数@H_301_1@

ajaxUpdate 是否启用AJAX请求数据@H_301_1@

ajaxUpdateError AJAX失败响应后调用的JAVASCRIPT函数@H_301_1@

ajaxUrl AJAX请求的URL@H_301_1@

ajaxVar AJAX请求,使用GET方式传送的变量@H_301_1@

baseScriptUrl 视图资源的URL@H_301_1@

beforeAjaxUpdate 在AJAX调用之前调用的JAVASCRIPT函数@H_301_1@

blankDisplay 列标题为空显示内容@H_301_1@

columns 内容列有配置@H_301_1@

controller 控制器@H_301_1@

cssFile 视图的样式@H_301_1@

dataProvider 视图的数据@H_301_1@

emptyText 内容为空显示的信息@H_301_1@

filterPosition 搜索框所在的位置@H_301_1@

更多关于Yii相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《》@H_301_1@

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。@H_301_1@

猜你在找的PHP相关文章