Search Form And Filter In Cjuidialog Doesn't Work

Hi Friends,

I need your help

I have a CJuiDialog that show a rendered view with a CGidView

as a normal window, so far so good however,

at a moment the use the native filter and search functions for a

find some records in my Grid View, it doesn’t work, only refresh the

CGridView but I don’t get filtered records my code is:

This is the link who calls CJuiDialog:




//this link call to controller action 'recibevalor' at te same time

// open the CJuiDialog

<?php echo CHtml::link('>>','#' ,array('onclick'=>'$("#cru-frame3").attr("src","'.Yii::app()->createurl("/inventario/recibevalor",).'"); $("#cru-dialog3").data("hilo","Inventario_coddocu").dialog("open"); return false',)); 

//Send parameter hilo ='Inventario_coddocu' with CJUIDialog

?>




<?php




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

    'id'=>'cru-dialog3',

    'options'=>array(

        'title'=>'Explorador',

        'autoOpen'=>false,

        'modal'=>true,

        'width'=>300,

        'height'=>300,

    ),

    ));

?>

<iframe id="cru-frame3" width="100%" height="100%"></iframe>

<?php

 

$this->endWidget();


?>



The code from my Controller




public function actionRecibevalor()

	{

		

		$autoIdAll=array();

		if(  isset($_POST['checkselected'])   ) //If user had posted the form with records selected

				{

				$autoIdAll = $_POST['checkselected']; ///The records selecteds 

				};

				if(count($autoIdAll)>0)

										{

	//THIS SCRIPT CLOSE THE DIALOG, RECEIVE THE PARAMETER AND STORE INTO VARIABLE 'CAJA'

	// Y PUTS IT INTO ANY INPUT TEXTBOX FRON THE ORIGINAL VIEW 								

echo CHtml::script("window.parent.$('#cru-dialog3').dialog('close');													                    

																		window.parent.$('#cru-frame3').attr('src','');

																		var caja=window.parent.$('#cru-dialog3').data('hilo');																																		

																		window.parent.$('#'+caja+'').attr('value','{$_POST['Buscador']['valortexto']}');																		

																		");

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

										} else{//If opens the dialog for first time 

												$model=new Inventario('search'); //modelo para los campos												

												$this->render("vw_pruebita1"),array('model'=>$model));

												}

										

	}




And the code from the view ‘vw_pruebita1’





<?php




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

$('.search-button').click(function(){

	$('.search-form').toggle();

	return false;

});

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

	$.fn.yiiGridView.update('documentos-grid', {

		data: $(this).serialize()

	});

	return false;

});

");

?>




<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>

<div class="search-form" style="display:none">

<?php

/* @var $this InventarioController */

/* @var $model Inventario */

/* @var $form CActiveForm */

?>


<div class="wide form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'action'=>Yii::app()->createUrl($this->route),

	'method'=>'get',

)); ?>

  <FIELDSET>

	

	

	<div style="height: 25px;margin:0;">

		

		

		

		<div style="float: left;  clear right;">

		<?php echo $form->textField($model,'desdocu',array('size'=>30,'maxlength'=>30)); ?>

		</div>

    </div>

	

		

	

	<div class="row buttons">

		<?php echo CHtml::submitButton('Filtrar'); ?>

	</div>

 </FIELDSET>

<?php $this->endWidget(); ?>




</div><!-- search-form -->


<?php $this->widget('zii.widgets.grid.CGridView', array(

	'id'=>'documentos-grid',

	'dataProvider'=>Documentos::model()->search(),

	'filter'=>$model,

	'columns'=>array(

						array(

									'class'=>'CCheckBoxColumn',

									'selectableRows' => 1, //select only a value

									'value'=>'$data->coddocu',

									'checkBoxHtmlOptions' => array(                

																'name' => 'checkselected[]',

																	),

         

		'coddocu',

		'desdocu',

		'clase',

		'tipo',

		

	),

)); ?>




Hi ,

you can check the function search in your model

i hope it’s look like this…


public function search() {

		$criteria = new CDbCriteria;

		$criteria->compare('id', $this->id, true);

		$criteria->compare('coddocu', $this->coddocu, true);

		

}

Thanks for Your help, I forgot that the ‘filter form’ into CGridview was calling

the method GET, in My controller I was waiting for array POST Variables. I solved

the problem writing the same code from action ‘admin’ from the controller that belong

the model used in the view rendered.

Thanks you very much…