Portion of my view(_form)
<table class="grid_view_table">
<tr colspan="2">
<td class="dropdown" style="width:50px">
<?php $select=""; echo CHtml::dropDownList('TYPE',$select,array('All'=>'All Training','My'=>'My Training'), array('empty' => '(--Select--)','class'=>'form-control input-sm','id'=>'Type')); ?>
</td>
<td>
</td>
</tr>
<tr colspan="2"><td>
<table id="training_calendar_table" class="table" style="width:920px;">
<thead style="width:920px;display: block;">
<tr>
<th width="80"> <?php echo $form->labelEx($model,'Start Date'); ?></th>
<th width="80"> <?php echo $form->labelEx($model,'End Date'); ?><?php //echo CHtml::link('Branch', '#', array('id' => 'sort_link', 'name'=>'branch','class' => 'desc')); ?></th>
<th width="150"> <?php echo $form->labelEx($model,'Course'); ?></th>
<th width="100"> <?php echo $form->labelEx($model,'Reference No'); ?></th>
<th width="50"> <?php echo $form->labelEx($model,'Term'); ?></th>
<th width="80"> <?php echo $form->labelEx($model,'Duration'); ?></th>
<th width="80"> <?php echo $form->labelEx($model,'No Seats'); ?></th>
<th width="150"> <?php echo $form->labelEx($model,'Institute'); ?></th>
<th width="120"> <?php echo $form->labelEx($model,'Targeted Audience'); ?></th>
</tr>
</thead>
<tbody style="width:840px; height:248px;float: left; overflow-y: auto; " >
<?php foreach($data as $rows) {
$falg=1;
?>
<tr >
<td width="80" style="padding-right: 10px"><?php echo $rows['START_DATE']; ?></td>
<td width="80"><?php echo $rows['END_DATE']; ?></td>
<td width="150"><?php echo $rows['START_DATE'] ?></td>
<td width="100"><?php echo $rows['TCS_TRAINING_COURSE_REF_NO'] ?></td>
<td width="50"><?php echo $rows['TCS_TRAINING_COURSE_REF_NO'] ?></td>
<td width="80"><?php echo $rows['TCS_COURSE_DURATION'] ?></td>
<td width="80"><?php echo $rows['TCS_NO_OF_SEAT'] ?></td>
<td width="150"><?php echo $rows['INSTITUTE_NAME'] ?></td>
<td width="80"><?php echo $rows['TCS_TARGET_CATEGORY'] ?></td>
<td>
</td>
</tr>
<?php } ?>
<tr><td> <?php if($flag==1){ ?><?php
//Get pagination result
// echo "hai".$cpage;
$this->widget('CLinkPager', array(
'pages'=>$dataProvider->pagination,
'itemCount'=>30,
'header'=>'',
)); ?> <?php } ?></td></tr>
</tbody>
</table>
My Ajax Call For DropDownlist:
<script>
$(document).ready(function(){
$('h3.box-title').text("Training Calendar"); //For Changing Box Title
change_box_width('950px');
$('#Type').change(function(){
var selected=$('#Type').val();
$.ajax({type:"POST",
url:"<?php echo Yii::app()->createUrl('Training_Calendar/ViewDetails'); ?>",
data: {svalue:selected}
}).success(function(html){
var data = jQuery.parseJSON(html);
$("#training--calendar-form").html(data.html_content);
$("#mydialog").remove();
});
});
});
</script>
Finally Action in my controller:
public function actionViewDetails(){
$model=new Training_Calendar;
if(Yii::app()->request->isAjaxRequest){
//
$selected=$_POST['svalue'];
if($selected=="All")
{
$count=1;
$sql=Training_Calendar::model()->getAllTraining();
//
$dataProvider=new CSqlDataProvider($sql, array(
'totalItemCount'=>30,
'pagination'=>array(
'pageSize'=>8,
),
));
$data = $dataProvider->getData();
$response_array = array();
$desc = $this->renderPartial('_form', array('model' => $model, 'data' => $data, 'dataProvider' => $dataProvider), true);
}
$response_array['html_content'] = $desc;
echo json_encode($response_array);
}
//
}