filter as you type in yii2 gridview

2019-04-08 22:54发布

问题:

I need to filter the gridview as you type. By default it filters only when the enter key is pressed.

回答1:

You should handle this using your own js, e.g. :

$this->registerJs('$("body").on("keyup.yiiGridView", "#grid-id .filters input", function(){
    $("#grid-id").yiiGridView("applyFilter");
})', \yii\web\View::POS_READY);

You should of course replace grid-id with appropriate id.