CGridView怎么在Yii框架中使用-創(chuàng)新互聯(lián)

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

專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計、網(wǎng)站制作服務,電腦端+手機端+微信端的三站合一,更高效的管理,為中小企業(yè)鄱陽免費做網(wǎng)站提供優(yōu)質(zhì)的服務。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動了上千多家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實現(xiàn)規(guī)模擴充和轉(zhuǎn)變。

CGridView的功能是用來顯示的數(shù)據(jù)列表。它支持排序,分頁,和AJAX數(shù)據(jù)請求。


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成功響應后調(diào)用的JAVASCRIPT函數(shù)

ajaxUpdate 是否啟用AJAX請求數(shù)據(jù)

ajaxUpdateError AJAX失敗響應后調(diào)用的JAVASCRIPT函數(shù)

ajaxUrl AJAX請求的URL

ajaxVar AJAX請求,使用GET方式傳送的變量

baseScriptUrl 視圖資源的URL

beforeAjaxUpdate 在AJAX調(diào)用之前調(diào)用的JAVASCRIPT函數(shù)

blankDisplay 列標題為空顯示的內(nèi)容

columns 內(nèi)容列有配置

controller 控制器

cssFile 視圖的樣式

dataProvider 視圖的數(shù)據(jù)

emptyText 內(nèi)容為空顯示的信息

filterPosition 搜索框所在的位置

關(guān)于CGridView怎么在Yii 框架中使用問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。

當前標題:CGridView怎么在Yii框架中使用-創(chuàng)新互聯(lián)
網(wǎng)頁網(wǎng)址:http://www.muchs.cn/article40/shoho.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供域名注冊、做網(wǎng)站網(wǎng)站內(nèi)鏈、標簽優(yōu)化、App設(shè)計、網(wǎng)站維護

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司