本文实例讲述了Yii CGridView用法。分享给大家供大家参考,具体如下:
CGridView的功能是用来显示的数据列表。它支持排序,分页,和AJAX数据请求。
CGridView最好使用 data provider,最好是 CActiveDataProvider 。
简单代码如下:
$dataProvider=new CActiveDataProvider('Post'); $this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$dataProvider, ));
详细示例:
$this->widget('zii.widgets.grid.CGridView', array( 'dataProvider'=>$dataProvider, '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', ), ), ));
属性说明:
actionPrefix 方法前辍
afterAjaxUpdate AJAX成功响应后调用的JAVASCRIPT函数
ajaxUpdate 是否启用AJAX请求数据
ajaxUpdateError AJAX失败响应后调用的JAVASCRIPT函数
ajaxUrl AJAX请求的URL
ajaxVar AJAX请求,使用GET方式传送的变量
baseScriptUrl 视图资源的URL
beforeAjaxUpdate 在AJAX调用之前调用的JAVASCRIPT函数
blankDisplay 列标题为空显示的内容
columns 内容列有配置
controller 控制器
cssFile 视图的样式
dataProvider 视图的数据
emptyText 内容为空显示的信息
filterPosition 搜索框所在的位置
更多关于Yii相关内容感兴趣的读者可查看本站专题:《Yii框架入门及常用技巧总结》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。
Yii,CGridView
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。