murid
(Darkstar Cc)
1
I confused with CActiveDataProvider, I try to make user list with this model script
public function listUser(){
$items = $this->findAll();
foreach ($items as $item)
$items = array('id_user'=>$item->id_user, 'username'=>$item->username, 'passwd'=>$item->passwd, 'email'=>$item->email, 'level'=>$item->level, 'status'=>$item->status);
return new CActiveDataProvider($this, $items);
}
and I got error message
please help me to know the wrong code
sorry with my english
softark
(Softark)
2
Hi yiistudent,
I’d like to ask you to explain your design a little more clearly:
What do you want to do with the returned data provider in your program?
Do you want to show a list of users in your view?
And do you want to use a CGridView or a CListView in your view?
Or, do you want just an array of users and you are going to loop through it in your view?
murid
(Darkstar Cc)
3
Thx for u’r response
I want call listUser method on my view with this code
$this->widget('bootstrap.widgets.BootGridView',array(
'type'=>'striped bordered condensed',
'template'=>"{items}",
'id'=>'user-grid',
'dataProvider'=>$model->listUser(),
'filter'=>$model,
'columns'=>array(
array('name'=>'id_user', 'header'=>'id'),
array('name'=>'username', 'header'=>'Username'),
array('name'=>'passwd', 'header'=>'Password'),
array('name'=>'email', 'header'=>'Email'),
array('name'=>'level', 'header'=>'Level'),
array('name'=>'status', 'header'=>'Status'),
array(
'class'=>'bootstrap.widgets.BootButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
),
),
));
softark
(Softark)
4
I see.
You could have used gii-generated ‘search’ method in your model code.
$this->widget('bootstrap.widgets.BootGridView',array(
'type'=>'striped bordered condensed',
'template'=>"{items}",
'id'=>'user-grid',
'dataProvider'=>$model->search(),
...
I think the default ‘search’ method is best suited for general purpose when you want to use CGridView or its extensions.