Hello
I´m using CGridView, this is my code:
model:
public function actionIndex()
{
$dataProvider = new CActiveDataProvider('Login');
$this->render('index',array('dataProvider'=>$dataProvider));
}
View
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'nome',
'nivel',
array('class'=>'CButtonColumn',),
),
));
?>
This code is ok. But there are 3 buttons "view", "update" and "delete" , I need remove the update button. How can I do this?
mbi
(mbi)
2
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'nome',
'nivel',
array(
'class'=>'CButtonColumn',
'template' => '{view} {delete}'
),
),
));
?>
http://www.yiiframework.com/doc/api/1.1/CButtonColumn
Thank you
I was read here:
http://www.yiiframework.com/doc/api/1.1/CGridView
I´m with another doubt, this line:
$dataProvider = new CActiveDataProvider(‘Login’);
fill a grid with all data of my table, but on another grids I need filter the data, so How can I do this?
I try something using $model = MyModel::model()->findbyPk($_GET[‘id’]); don´t run.
Could you explain how to do this?
dudhi
(Rohitduhan)
4
If you look over, you are using dataProvider in the first reference $dataProvider = new CActiveDataProvider(‘Login’
and model for the second.
With datprovider you should be able to do something like this
$dataProvider = new CActiveDataProvider(‘ModelName’, array (
'criteria'=>array(
'condition'=>$condition,
'compare'=>$compare,
),
));
If you are doing using Model, then
$post = ModelName::model()->findByPk(id);
Should work as long as id is a primary key
Thanks for help. I gonna try and back with the answer
Hello
How can I do to change the default text of deleteConfirmation of CGridView? I´m reading this documentation
http://www.yiiframework.com/doc/api/1.1/CButtonColumn#deleteConfirmation-detail
But I did not find anything.
phtamas
(Phtamas)
7
Have you tried to set the property?
array(
'class' => 'CButtonColumn',
'deleteConfirmation' => 'My custom message',
),
Thank you for help Rohit Duhan
I test the example and worked very well.
All my problems was solved with this post.