Yii Framework Forum: Gridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Gridview

#1 User is offline   n-r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 127
  • Joined: 19-April 13

Posted 04 May 2013 - 02:38 AM

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
0

#2 User is offline   dhanakumar 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 26-December 12
  • Location:Coimbatore,Tamilnadu

Posted 04 May 2013 - 03:56 AM

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,

View Postn-r, on 04 May 2013 - 02:38 AM, said:

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

-
Dhana.M
0

#3 User is offline   n-r 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 127
  • Joined: 19-April 13

Posted 04 May 2013 - 04:02 AM

View Postdhanakumar, on 04 May 2013 - 03:56 AM, said:

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
0

#4 User is offline   emmi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 02-December 13

Posted 16 December 2013 - 01:36 AM

hi all,

controller
$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
0

#5 User is offline   Ravi Bhalodiya 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 27-August 12
  • Location:Gujarat India

Posted 19 December 2013 - 05:48 AM

Can not understand what are you actually trying to do?? Please use code snippet to make your code clear and readable..
Regards
Ravi Bhalodiya.
0

#6 User is offline   emmi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 02-December 13

Posted 20 December 2013 - 12:00 AM

View PostRavi Bhalodiya, on 19 December 2013 - 05:48 AM, said:

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users