I have CGridView which is working well.
Now, I need search feature for model represented in CGridView. My wish is to use one textField where user will type some text. While user is typing (event onKeyUp) the value in textField must be sent to controller via Ajax to some SQL query (jquery) and response will be shown in CGridView. The SQL query must search to all columns (fields) of model table.
Any idea HOW TO use AJAX for this situation? Do I need CActiveForm? What I must write in controller and model?
Ok. Here is my code in view.
<?php $form=$this->beginWidget('CActiveForm', array(
'id'=>'customsearch-form',
'enableAjaxValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true, 'validateOnChange'=>true),
'htmlOptions'=>array('enctype' => 'text/plain'),
));
echo CHtml::textField('TextSearch', 'Search',
array('id'=>'tbSearchKeyword',
'width'=>100,
'maxlength'=>100,
));
$this->endWidget();
?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'requests-grid1',
'dataProvider'=>$dataProvider,
//'filter'=>$model,
'columns'=>array(
'REQ_ID',
'USER_Name',
'REQ_RequestDate',
'REQ_DescriptionText',
'REQ_Beneficiary',
'REQ_Due',
//'REQ_CurrencySymbol',
array(
'name' => 'REQ_CurrencySymbol',
'header' => 'Curr.'
),
//'REQ_Amount',
array(
'name' => 'REQ_Amount',
'htmlOptions'=>array('style'=>'text-align:right'),
),
'REQ_Status',
array(
'class'=>'CButtonColumn',
),
),
)); ?>