weina67
(Weinanas)
August 17, 2011, 12:08pm
1
So I used CListView and CArrayDataProvider
$this->widget(‘zii.widgets.CListView’, array(
'dataProvider'=> $dataProvider,
'itemView'=>'_viewsearch',
'template'=>"{items}\n{pager}",
));
where dataProvider is a CArrayDataProvider but the list view widget is not recognizing the data provider. Does CLISTVIEW work with CArrayDataProvider? If not, how can I make it work?
Hi
yes, you can use CArrayDataProvider with CListView. Can show the code for creating the CArrayDataProvider ?
weina67
(Weinanas)
August 17, 2011, 3:04pm
3
Here’s the code:
$sql = "SELECT profiles.firstname, profiles.lastname, friendship.inviter_id, friendship.friend_id, profiles.user_id, friendship.status FROM profiles INNER JOIN friendship ON (profiles.user_id = friendship.inviter_id AND friendship.friend_id = '" . Yii::app()->user->id . "') OR (profiles.user_id = friendship.friend_id AND friendship.inviter_id = '" . Yii::app()->user->id . "') WHERE profiles.firstname LIKE '%" . $search . "%' OR profiles.lastname LIKE '%" . $search . "%'";
$rawData = $conn->createCommand($sql)->queryAll();
$dataProvider= new CArrayDataProvider($rawData, array(
'id'=>'search_friends',
'sort'=>array(
'attributes'=>array(
'firstname',
), ),
'pagination'=>array(
'pageSize'=>10,
),));
Well the code looks ok … check out what is in $rawData and after all do you get an error or what ?
radames
(Radameh)
December 14, 2011, 6:54pm
5
So,
I do like this ,
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'verfpf-grid',
'dataProvider'=>[b]new CArrayDataProvider(Verfpf::getIndexfpf()),[/b]
'columns'=>array(
'ds_cronog',
'nr_verfpf',
'nr_controle',
but, the ID is not here
array(
'class'=>'CButtonColumn',
),
give a help please
tanks …