Yii Framework Forum: Yii Framework Submitbutton Ajaxsubmitbutton Out Side The Cgridview Manage The Row Values With Setflash - Yii Framework Forum

Jump to content

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

Yii Framework Submitbutton Ajaxsubmitbutton Out Side The Cgridview Manage The Row Values With Setflash CGridView with button to mange and update row/tuple values. Rate Topic: -----

#1 User is offline   SrikanthMaggidi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 19-May 14
  • Location:Hyderabad,India

Posted 28 May 2014 - 06:45 AM

In View::

<div id="updateDiv">
<?php 	foreach(Yii::app()->user->getFlashes() as $key => $message) 
					{
					echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
					}
?>
</div>

<?php echo CHtml::beginForm(); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'Test_Grid_view',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		'attribute1',
		'attribute2',
		array(
		       'id' => 'selectedGridRowId',
		       'class'=>'CCheckBoxColumn',
		 	 ),
	
		),
)); ?>

<!--submitButton-->
<div align="right">
<?php echo CHtml::submitButton('ManageCgridView', array('name' => 'ManageCgridView')); ?>
	<?php echo CHtml::submitButton('Cancel',array('name'=>'cancel')); ?>
<?php echo CHtml::endForm(); ?>
</div>

<!--ajaxSubmitButton-->
<div align="right">	
				
<?php	echo CHtml::ajaxSubmitButton("ManageCgridView", $this->createUrl('/Controller/action'),
 array(
 "type" => "post",
"data" => "js:{chk:$.fn.yiiGridView.getSelection('Test_Grid_view')}",
"update" => "#updateDiv",
'beforeSend' => "function() { $.fn.yiiGridView.update('Test_Grid_view', {    data:'data',});        }",
)); ?>

</div>


In Controller::

Action For submitButton:
<?php
	public function actionSubmitAction()
	{
	if (isset($_POST['ManageCgridView']))
    {
        if (isset($_POST['selectedGridRowId']))
        {
        echo "Selected Grid view Id is ==".$_POST['selectedGridRowId'][0];
		$model=new Model;
		//do functionality
		}
		else 
		{
		Yii::app()->user->setFlash('notice', "Please set flash notification here");
		$this->redirect(array('action'));
		}
	}
		$model=new Model('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Model']))
			$model->attributes=$_GET['Model'];
	$this->render('viewFile',array('model'=>$model,));
	}
?>



Action For ajaxSubmitButton::

<?php
	public function actionAjaxSubmitAction()
	{	
	  if(isset($_POST['chk']))	
		{
		echo $_POST['chk'][0];
		//do functionality
		
		$model=new Model('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Model']))
			$model->attributes=$_GET['Model'];

		$this->renderPartial('ViewFile',array('model'=>$model),false,true);
		}
		  
		else
				{
					Yii::app()->user->setFlash('notice', "Please set flash notification here");
					foreach(Yii::app()->user->getFlashes() as $key => $message) 
					{
					echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
					}
				}   
	}
	
	?>


Please post comment for any queries

Thanks,
Srikanth
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