Gridview

hi

Show view:


  

 $this->widget('zii.widgets.grid.CGridView', array(

     'dataProvider'=> $model,

     'id'=>'showlog',

       'columns'=>

           array(array(

               'id',

               'sid',

               'entertime',

               'outtime',

 ),), )); 

   

   $this->endWidget(); 



Show controller:




 $model=  Logging::model()->findAll();

$this->render('ShowLog',array('model'=>$model)); 



in browser:

Fatal error: Call to a member function getData() on a non-object in D:\wamp\www\framework\zii\widgets\CBaseListView.php on line 107

where is Wrong???

thank you

can you use any dataprovider . ?

eg :

use model

public function userRoleMenuCompare($role_id)

{


   $rawData=Yii::app()->db->createCommand("select rmt_menu_id,rmt_role_menu_act from rmt_map_role_menu where rmt_role_id=".$role_id."")->queryAll();


   $dataprovider = new CArrayDataProvider($rawData,array('pagination'=>false));


   //print_r($dataprovider);exit;


   return $dataprovider->getData();


}

in view

$this->widget(‘zii.widgets.grid.CGridView’, array(

 'dataProvider'=> $model->userRoleMenuCompare,

very thanks, it’s right


[/code]hi all,


controller

[code]

$model=Product::model()->display_products_statistics();

		//$model->unsetAttributes();  // clear any default values

		//if(isset($_GET['Product']))

			//$model->attributes=$_GET['Product'];


		$this->render('admin',array(

			'model'=>$model,

		));




view







<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'product-grid',

	'dataProvider'=>$model->display_products_statistics(),

	'filter'=>$model,

	'columns'=>array(

		'member_count',

		'seller_count',

		'visitor_count',

		/*'Higest price',

		'lowest price',

		/*

		'desc',

		/*

		'price',

		'createdate',

		'updatedate',

		'opid',

		'pimg',

		*/

		array(

			'class'=>'CButtonColumn',

			//'template'=>'{update}'

		),

	),

)); ?>




model




$sql="select member_count,seller_count,

		visitor_count from fc_product fp

		group by  member_count,visitor_count,seller_count

		order by member_count desc";

		$connection=Yii::app()->db;

		$command=$connection->createCommand($sql);

		$products_statistics=$command->queryAll();

$dataprovider=new CArrayDataProvider($products_statistics,

 array('pagination'=>false));

		//print_r($dataprovider);exit;

		

		return $dataprovider->getData();



but then i am getting this error




Fatal error: Call to a member function getData() on a non-object in D:\wamp\www\yii\framework\zii\widgets\CBaseListView.php on line 111



I am confused and dont know whats going wrong

Plz let me know

Can not understand what are you actually trying to do?? Please use code snippet to make your code clear and readable…

for know update the code with the proper format