【问题标题】:yii filter without press tab/enteryii 过滤器没有按 tab/enter
【发布时间】:2016-10-29 05:43:21
【问题描述】:

我需要将 yii gridview 过滤器更改为自动搜索(不是自动完成)。例如,我有一个项目名称:StackOverflow。为此,我需要输入 stack 然后按 tab/enter 来获得结果。如果我输入 Sta,项目将显示哪些项目以字母 sta 开头(无需按 Tab/Enter 键)。帮帮我。谢谢

【问题讨论】:

    标签: php yii


    【解决方案1】:
    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);
                                                }'
                                            ),
                                ));
                            ?>
    

    【讨论】:

      猜你喜欢
      • 2014-02-18
      • 1970-01-01
      • 2011-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-16
      • 2020-07-30
      • 2014-09-14
      相关资源
      最近更新 更多