Refreshing Cgridview In A Dialog

Hello:

I was wondering if anyone has come up with a way to refresh a grid that is contained in a dialog? What I don’t want to do is have to re-render the whole page but rather I’d like to be able to just return the updated data for the grid. Here’s an example of my code:




	$this->beginWidget('zii.widgets.jui.CJuiDialog',array(

			'id'=>'events-print-dialog',

			// additional javascript options for the dialog plugin

			'options'=>array(

					'title'=>'Select Instructors To Email',

					'autoOpen'=>false,

					'width'=>775,

					'height'=>700,

			),

	));		

		echo CHtml::beginForm();

		echo '<div id="print-grid"></div>';

		

		$this->widget('bootstrap.widgets.TbExtendedGridView', array(

			'id'=>'email-grid',

			'type' => 'striped bordered',

			'dataProvider' => $taskProvider,

			'template' => "{items}",

			'selectableRows'=>'2',

			'bulkActions' => array(

				'actionButtons' => array(

					array(

						'buttonType' => 'button',

						'type' => 'primary',

						'size' => 'small',

						'label' => 'Send Email',

						'click' => 'js:function(values)

						{

							$.fn.yiiGridView.update("email-grid");

							alert("Hello");

						}',

						'id'=>'send_id'

					)

				),

				'checkBoxColumnConfig' => array(

						'name' => 'task_id'

				),

			),

	

			'columns' => array(														

				'title',						

			)

		));


         echo CHtml::endForm();

		

	$this->endWidget();



Thanks for your help!

If you don’t want to reload whole page, just update the content in the dialog, try to use AJAX way.

I tried it by CGridView, it works.




<?php

Yii::app()->clientScript->registerScript('search', "

$('.search-form form').submit(function(){

	$('#tool-grid').yiiGridView('update', {

		data: $(this).serialize()

	});

	return false;

});

");

?>