我需要将yii gridview过滤器更改为自动搜索(不是自动完成)。例如,我有一个项目名称: StackOverflow 。为此,我需要输入堆栈,然后按tab / enter以获取结果。如果我输入 Sta ,项目将显示哪些项目以字母 sta 开头(没有按Tab键/输入键)。帮助我。谢谢你
答案 0 :(得分:0)
Hi please use below widget
<input type="hidden" name="formula_formula" id="formula_formula" value="">
<?php
$this->widget('zii.widgets.jui.CJuiAutoComplete',
array(
'name'=>'tff',
'source'=>'js: function(request, response) {
$.ajax({
url: "'.$this->createUrl('youraction').'",
dataType: "json",
data: {
term: request.term,
name: "treatment_formula_formula",
pk : "tff_id"
},
success: function (data) {
response(data);
}
})
}',
'htmlOptions'=> array('placeholder'=>'Formula List', 'class' => 'form-control auto_comp_search'),
'options' => array(
'autoFocus' => true,
'showAnim' => 'fold',
'minLength' => '0',
'select'=>'js:function( event, ui ) {
$(ui).hide();
$("#formula_formula").val(ui.item.id);
}'
),
));
?>