Yii Framework Forum: Cjuidialog In Cgridview - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cjuidialog In Cgridview Rate Topic: -----

#1 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 10-February 12

Posted 01 March 2014 - 02:19 AM

Good day to all master, i have a problem, i use cjuidialog on my cgridview VIEW button, the scenario is when you click VIEW button the pop up cjuidialog appear, i dont have problem opn this part, but when i try to filter or search on the same cgriview and click VIEW the system will redirect to page that i need to pop up.. and thats my problem,

i attached a picture, first picture when i click VIEW button without filter/search, the second picture is my problem when i filter/search.

here is my code:
my controller:
	public function actionProcess($id)
	{
		$model=$this->loadModel($id);
                $employee = new CmtProcess;


		if(isset($_POST['FacultySched']))
		{
			$model->attributes=$_POST['FacultySched'];
                        $employee->attributes=$_POST['CmtProcess']; 
                        
                        $employee->empno=$model->empno;
                        $employee->sched_id=$model->id;
                        $employee->checking_time=$employee->checking_time;
                        $employee->nostud_notecher=$employee->nostud_notecher;
                        $employee->date_of_absence=$employee->date_of_absence;
                        
                 
			if($employee->save())
				$this->redirect(array('admin','id'=>$model->id));
		}
           
                    $this->renderPartial('process', array(
                        'model' => $model,
                        'employee' => $employee,
                    ));

                    Yii::app()->end();

                    }


my grid view
<?php 
$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'faculty-sched-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
                        
		 array(
                    'class' => 'SCLinkColumnWithSort',
                    'name'=>'search_lname',
                    'labelExpression'=>'$data->empno0->lname . ", " .$data->empno0->fname',
                    'urlExpression'=>'Yii::app()->createUrl("FacultySched/schedule",array("empno"=>$data["empno"]))',
                    'linkHtmlOptions'=>array('target'=>'_blank'),                     
                    'headerHtmlOptions'=>array('style'=>'width: 120px; text-align: center;'),
                    'header'=>'Full Name',
                ),
                array(
                  'name'=>'subject',        
                  'headerHtmlOptions'=>array('style'=>'width: 180px; text-align: center;'),
                   
                ),
            
                 array(
                     'name'=>'search_schoolcollege',  
                     'value'=>'$data->empno0->schoolCollege->name',
                     'filter'=>CHtml::listData(SchoolCollege::model()->findAll(array('order'=>'name')), 'id', 'name'),

  
                ),
                
        
               
		'time_from',
		'time_to',
		'days',
		'room',
		
		array(
		
                    'class'=>'CButtonColumn',
                    'header'=>CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,100=>100),array(
                    // change 'user-grid' to the actual id of your grid!!
                      'onchange'=>"$.fn.yiiGridView.update('faculty-sched-grid',{ data:{pageSize: $(this).val() }})",
                      )),
                    'template'=>'{view}',
                    'htmlOptions'=>array(
                            'width'=>50,
                    ),
                    'buttons' => array(
                            'view'=>array(
                                    'label'=>'Process',
                                    'url'=>'Yii::app()->createUrl("FacultySched/Process", array("id"=>$data->id))',
                                    'visible'=> '$data->days != NULL',
                                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/46.png',
                                    'options'=>array('class'=>'open_dialog'),
                                
                        ),
                   ),
                       
		),
	),
)); 

?>
<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog',array(
    'id'=>'mydialog',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Process',
        'modal'=>true,
        'autoOpen'=>false,
    ),
));?>
<?php
$this->endWidget('zii.widgets.jui.CJuiDialog');

?>
<script type="text/javascript">
    function open_dialog()
    {
       // e.preventDefault();
        var $this = jQuery(this);
        var $d = jQuery('#mydialog').load($this.attr('href')).dialog('open');
        return false;
    }
    jQuery(function(){
        jQuery('.open_dialog').click(open_dialog);
        
    });
</script>
    

Attached File(s)


0

#2 User is offline   alirz23 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,102
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 01 March 2014 - 04:50 AM

look at the line I commented add it in your CGridView





<?php 
$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
$this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'faculty-sched-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'afterAjaxUpdate'=>'js:function(){  jQuery('.open_dialog').click(open_dialog); }',   //this should fix it
        'columns'=>array(
                        
                 array(
                    'class' => 'SCLinkColumnWithSort',
                    'name'=>'search_lname',
                    'labelExpression'=>'$data->empno0->lname . ", " .$data->empno0->fname',
                    'urlExpression'=>'Yii::app()->createUrl("FacultySched/schedule",array("empno"=>$data["empno"]))',
                    'linkHtmlOptions'=>array('target'=>'_blank'),                     
                    'headerHtmlOptions'=>array('style'=>'width: 120px; text-align: center;'),
                    'header'=>'Full Name',
                ),
                array(
                  'name'=>'subject',        
                  'headerHtmlOptions'=>array('style'=>'width: 180px; text-align: center;'),
                   
                ),
            
                 array(
                     'name'=>'search_schoolcollege',  
                     'value'=>'$data->empno0->schoolCollege->name',
                     'filter'=>CHtml::listData(SchoolCollege::model()->findAll(array('order'=>'name')), 'id', 'name'),

  
                ),
                
        
               
                'time_from',
                'time_to',
                'days',
                'room',
                
                array(
                
                    'class'=>'CButtonColumn',
                    'header'=>CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,100=>100),array(
                    // change 'user-grid' to the actual id of your grid!!
                      'onchange'=>"$.fn.yiiGridView.update('faculty-sched-grid',{ data:{pageSize: $(this).val() }})",
                      )),
                    'template'=>'{view}',
                    'htmlOptions'=>array(
                            'width'=>50,
                    ),
                    'buttons' => array(
                            'view'=>array(
                                    'label'=>'Process',
                                    'url'=>'Yii::app()->createUrl("FacultySched/Process", array("id"=>$data->id))',
                                    'visible'=> '$data->days != NULL',
                                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/46.png',
                                    'options'=>array('class'=>'open_dialog'),
                                
                        ),
                   ),
                       
                ),
        ),
)); 

?>


0

#3 User is offline   raiethan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 94
  • Joined: 10-February 12

Posted 02 March 2014 - 08:03 PM

View Postalirz23, on 01 March 2014 - 04:50 AM, said:

look at the line I added and and add it in your CGridView





<?php 
$pageSize=Yii::app()->user->getState('pageSize',Yii::app()->params['defaultPageSize']);
$this->widget('zii.widgets.grid.CGridView', array(
        'id'=>'faculty-sched-grid',
        'dataProvider'=>$model->search(),
        'filter'=>$model,
        'afterAjaxUpdate'=>'js:function(){  jQuery('.open_dialog').click(open_dialog); }',   // add this line should fix it
        'columns'=>array(
                        
                 array(
                    'class' => 'SCLinkColumnWithSort',
                    'name'=>'search_lname',
                    'labelExpression'=>'$data->empno0->lname . ", " .$data->empno0->fname',
                    'urlExpression'=>'Yii::app()->createUrl("FacultySched/schedule",array("empno"=>$data["empno"]))',
                    'linkHtmlOptions'=>array('target'=>'_blank'),                     
                    'headerHtmlOptions'=>array('style'=>'width: 120px; text-align: center;'),
                    'header'=>'Full Name',
                ),
                array(
                  'name'=>'subject',        
                  'headerHtmlOptions'=>array('style'=>'width: 180px; text-align: center;'),
                   
                ),
            
                 array(
                     'name'=>'search_schoolcollege',  
                     'value'=>'$data->empno0->schoolCollege->name',
                     'filter'=>CHtml::listData(SchoolCollege::model()->findAll(array('order'=>'name')), 'id', 'name'),

  
                ),
                
        
               
                'time_from',
                'time_to',
                'days',
                'room',
                
                array(
                
                    'class'=>'CButtonColumn',
                    'header'=>CHtml::dropDownList('pageSize',$pageSize,array(10=>10,20=>20,100=>100),array(
                    // change 'user-grid' to the actual id of your grid!!
                      'onchange'=>"$.fn.yiiGridView.update('faculty-sched-grid',{ data:{pageSize: $(this).val() }})",
                      )),
                    'template'=>'{view}',
                    'htmlOptions'=>array(
                            'width'=>50,
                    ),
                    'buttons' => array(
                            'view'=>array(
                                    'label'=>'Process',
                                    'url'=>'Yii::app()->createUrl("FacultySched/Process", array("id"=>$data->id))',
                                    'visible'=> '$data->days != NULL',
                                    'imageUrl'=>Yii::app()->request->baseUrl.'/images/46.png',
                                    'options'=>array('class'=>'open_dialog'),
                                
                        ),
                   ),
                       
                ),
        ),
)); 

?>



@alirz23 - THANK YOU!!!!!!!
'afterAjaxUpdate'=>'js:function(){ jQuery(".open_dialog").click(open_dialog); }',
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users