属性“CGridView.data"没有定义


Property "CGridView.data" is not defined

我正在使用Yii框架,我试图添加一些东西到我的数据库,我得到这个错误:

            CException
Property "CGridView.data" is not defined.
C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CWidgetFactory.php(161)
149         if(isset($this->widgets[$className]))
150             $properties=$properties===array() ? $this->widgets[$className] : CMap::mergeArray($this->widgets[$className],$properties);
151         if($this->enableSkin)
152         {
153             if($this->skinnableWidgets===null || in_array($className,$this->skinnableWidgets))
154             {
155                 $skinName=isset($properties['skin']) ? $properties['skin'] : 'default';
156                 if($skinName!==false && ($skin=$this->getSkin($className,$skinName))!==array())
157                     $properties=$properties===array() ? $skin : CMap::mergeArray($skin,$properties);
158             }
159         }
160         foreach($properties as $name=>$value)
161             $widget->$name=$value;
162         return $widget;
163     }
164 
165     /**
166      * Returns the skin for the specified widget class and skin name.
167      * @param string $className the widget class name
168      * @param string $skinName the widget skin name
169      * @return array the skin (name=>value) for the widget
170      */
171     protected function getSkin($className,$skinName)
172     {
173         if(!isset($this->_skins[$className][$skinName]))
Stack Trace
#0  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CWidgetFactory.php(161): CComponent->__set("data", Document)
#1  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CBaseController.php(146): CWidgetFactory->createWidget(DocumentController, "zii.widgets.grid.CGridView", array("data" => Document, "attributes" => array("id", "file_id", "timestamp", "description", ...)))
#2  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CBaseController.php(180): CBaseController->createWidget("zii.widgets.grid.CGridView", array("data" => Document, "attributes" => array("id", "file_id", "timestamp", "description", ...)))
#3  
–  C:'wamp'www'testdrive - 18-05-2015'private'protected'views'document'view.php(30): CBaseController->widget("zii.widgets.grid.CGridView", array("data" => Document, "attributes" => array("id", "file_id", "timestamp", "description", ...)))
25         'file_id',
26         'timestamp',
27         'description',
28         'content',
29     ),
30 )); ?>
#4  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CBaseController.php(126): require("C:'wamp'www'testdrive - 18-05-2015'private'protected'views'docum...")
#5  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CBaseController.php(95): CBaseController->renderInternal("C:'wamp'www'testdrive - 18-05-2015'private'protected'views'docum...", array("model" => Document), true)
#6  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(869): CBaseController->renderFile("C:'wamp'www'testdrive - 18-05-2015'private'protected'views'docum...", array("model" => Document), true)
#7  
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(782): CController->renderPartial("view", array("model" => Document), true)
#8  
–  C:'wamp'www'testdrive - 18-05-2015'private'protected'controllers'DocumentController.php(56): CController->render("view", array("model" => Document))
51      */
52     public function actionView($id)
53     {
54         $this->render('view',array(
55             'model'=>$this->loadModel($id),
56         ));
57     }
58 
59     /**
60      * Creates a new model.
61      * If creation is successful, the browser will be redirected to the 'view' page.
#9  
 unknown(0): DocumentController->actionView("13")
#10 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'actions'CAction.php(109): ReflectionMethod->invokeArgs(DocumentController, array("13"))
#11 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'actions'CInlineAction.php(47): CAction->runWithParamsInternal(DocumentController, ReflectionMethod, array("id" => "13"))
#12 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(308): CInlineAction->runWithParams(array("id" => "13"))
#13 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'filters'CFilterChain.php(133): CController->runAction(CInlineAction)
#14 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'filters'CFilter.php(40): CFilterChain->run()
#15 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(1145): CFilter->filter(CFilterChain)
#16 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'filters'CInlineFilter.php(58): CController->filterAccessControl(CFilterChain)
#17 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'filters'CFilterChain.php(130): CInlineFilter->filter(CFilterChain)
#18 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(291): CFilterChain->run()
#19 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CController.php(265): CController->runActionWithFilters(CInlineAction, array("accessControl", "postOnly + delete"))
#20 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CWebApplication.php(282): CController->run("view")
#21 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'web'CWebApplication.php(141): CWebApplication->runController("document/view")
#22 
+  C:'wamp'www'testdrive - 18-05-2015'yii'framework'base'CApplication.php(184): CWebApplication->processRequest()
#23 
–  C:'wamp'www'testdrive - 18-05-2015'public'index.php(18): CApplication->run()
13 defined('YII_DEBUG') or define('YII_DEBUG',true);
14 // specify how many levels of call stack should be shown in each log message
15 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
16 
17 require_once($yii);
18 Yii::createWebApplication($config)->run();
19 ?>

我不确定到底是哪里出了问题。我有4其他表在我的数据库,这是唯一一个,它不会工作,它给出了一个错误。你能给我解释一下哪里出了问题吗?问题是从我的数据库??

CGridView以表的形式显示数据项列表。

异常,因为CGidView没有属性'data'。类有属性'dataProvider'。下面是一个简单的CGridView示例。您可以使用GII从您的模型生成示例。

// in your view.
$this->widget('zii.widgets.grid.CGridView', array(
    'id' => 'document',
     // you can't use key 'data' here
    'dataProvider' => $document->search(), // @var Document $document - your model
    'columns' => array(
      'id', 
      // ... other properties
    )
));
// in model Document
public function search()
{
    $criteria = new CDbCriteria();
    $criteria->compare('id',$this->id);
    //$criteria->compare('one_more_poperty', $this->one_more_poperty);
    ...
    return new CActiveDataProvider($this, array(
        'criteria'=>$criteria,
    ));
}