Find us on facebook

Aug 2, 2014

Button visibility in Grid view

array(
'class'=>'bootstrap.widgets.TbButtonColumn',
'template'=>'{view}{edit}{delete}',
'buttons'=>array
(


'view' => array
(
'label'=>'View',
'visible' => '(isset($data->id))?false:true;',
'url'=>'Yii::app()->createUrl("MainMenu/view", array("id"=>$data->id))',
'imageUrl' => Yii::app()->baseUrl . '/images/icon/viewicon.jpg',
'options'=>array(
'style'=>'width:130px;height:130px;',
//   'class'=>'btn btn-small btn-info',
),
),

CDbCriteria with grid searching ability

$criteria=new CDbCriteria;
$res_id = CF::get_resid();
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('create_date',$this->create_date,true);
$criteria->compare('res_id',$res_id);
$criteria->compare('is_active',$this->is_active);
$criteria->addSearchCondition('is_active', 1);
$criteria->addSearchCondition('res_id', $res_id);
//condition = "is_active=:is_active AND res_id=:res_id";
//$criteria->params = array(':is_active'=>1,':res_id'=>$res_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>array(
                        'pageSize'=>4,
                ),
));

Aug 1, 2014

Call AJAX function when checkbox change

echo CHtml::checkbox("actions[]",true, array("value"=>"$keydes-$Authitem"));


<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerScript('updateAction', '
$(":checkbox").change(function()
{
var value =$(this).val();

var check = $(this).attr("checked");


$.ajax({

 url: "' . Yii::app()->createAbsoluteUrl('rights/Authitemchild/Update').'",
 type:"POST",
 data: "value="+value+"&check=" + check,
 //dataType:"json",
 success: function(responce)

 {
alert(responce);

 }

});

});

',CClientScript::POS_READY);
?>