i want add a checkbox on per row,can I?
i want add a checkbox on per row,can I?
me too, and add javascript action when checked!
I solved. like this:
<?php $this->widget('zii.widgets.grid.CGridView', array(
'dataProvider'=>$dataProvider,
'columns'=>array(
'id',
array(
'name'=>'', 'value'=>'CHtml::checkBox("cid[]",null,array("value"=>$data->id,"id"=>"cid_".$data->id))',
'type'=>'raw',
'htmlOptions'=>array('width'=>5),
//'visible'=>false,
),
'name',
'email',
),
)); ?>
if you want check the checkbox is checked or not,use this javascript before you submit:
var item = $("form input:checkbox:checked");
if(item.length==0) {
alert('Plese select checkbox!');
return false;
}
thank you very much
Hi,
I am newly using YII and need the same thing what you did. Can you help me how to add delete/update button or link on the top and also need the action for delete and update? It will really help me alot
THank\
Can anyone help me plz? I really appreciate if anyone help me about my problem.
PLZ help me
Plz Help me.
Can you post the action controller? I m doing the same thing.
THis action controller is not working
public function actionMultiupdate()
{
$this->_model=TnRecords::model()->updateAll(array("User_id"=>0),"id IN (" .implode(",",$_POST["cid"]).")");
$this->redirect(array('admin'));
}
I got this error
Description
implode() [<a href=‘function.implode’>function.implode</a>]:
Invalid arguments passed
Have any idea?
There is a CCheckBox class that works too…
It only seems to have some css selection error with me
http://www.yiiframework.com/doc/api/CCheckBoxColumn
Example…
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'post-grid',
'dataProvider'=>$model->search(),
'filter'=>$model,
'selectableRows' => 2,
'columns'=>array(
array(
'class'=>'CCheckBoxColumn',
),
array(
'name' => 'id',
'htmlOptions' => array('style'=>'width:30px;'),
),
array(
'name'=>'status',
'value'=> '$data->getStatusName($data->status);',
),
'title',
array(
'name'=>'created',
'value'=> 'Yii::app()->getDateFormatter()->format("dd-MM-yyyy",$data->created);',
),
array(
'class'=>'CButtonColumn',
)
),
)); ?>
Here’s an example of CGridView with CCheckboxColumn, Select All and an Action Button:
<?php
$this->widget(‘zii.widgets.grid.CGridView’, array(
'id' => 'a-grid-id',
'dataProvider' => $model,
'ajaxUpdate' => true, //false if you want to reload aentire page (useful if sorting has an effect to other widgets)
'filter' => null, //if not exist search filters
'columns' => array(
array(
'name'=>'Check',
'value'=>'CHtml::checkBox("cid[]",null,array("value"=>$data[\'Eid\']))',
'type'=>'raw',
'htmlOptions'=>array('width'=>5),
//'visible'=>false,
),
'Eid',
'AName',
'prdcName',
'NextContDate',
'NextAction',
array(
'name'=>'Mail',
'type'=>'raw',
'value'=>function($data)
{
if ($data['Email']!="")
{
CHtml::mailto($email=$data['Email']);
}else
{
echo "Email not specified";
}
},
),
),
)); ?>