CGridView怎么在Yii 框架中使用?針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

CGridView的功能是用來(lái)顯示的數(shù)據(jù)列表。它支持排序,分頁(yè),和AJAX數(shù)據(jù)請(qǐng)求。
CGridView好使用 data provider,好是 CActiveDataProvider 。
簡(jiǎn)單代碼如下:
$dataProvider=new CActiveDataProvider('Post');
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
));詳細(xì)示例:
$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',
),
),
));屬性說(shuō)明:
actionPrefix 方法前輟
afterAjaxUpdate AJAX成功響應(yīng)后調(diào)用的JAVASCRIPT函數(shù)
ajaxUpdate 是否啟用AJAX請(qǐng)求數(shù)據(jù)
ajaxUpdateError AJAX失敗響應(yīng)后調(diào)用的JAVASCRIPT函數(shù)
ajaxUrl AJAX請(qǐng)求的URL
ajaxVar AJAX請(qǐng)求,使用GET方式傳送的變量
baseScriptUrl 視圖資源的URL
beforeAjaxUpdate 在AJAX調(diào)用之前調(diào)用的JAVASCRIPT函數(shù)
blankDisplay 列標(biāo)題為空顯示的內(nèi)容
columns 內(nèi)容列有配置
controller 控制器
cssFile 視圖的樣式
dataProvider 視圖的數(shù)據(jù)
emptyText 內(nèi)容為空顯示的信息
filterPosition 搜索框所在的位置
關(guān)于CGridView怎么在Yii 框架中使用問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。
當(dāng)前標(biāo)題:CGridView怎么在Yii框架中使用-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)網(wǎng)址:http://chinadenli.net/article40/shoho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊(cè)、做網(wǎng)站、網(wǎng)站內(nèi)鏈、標(biāo)簽優(yōu)化、App設(shè)計(jì)、網(wǎng)站維護(hù)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容