B
B
bizzonaru2017-03-07 11:33:01
Yii
bizzonaru, 2017-03-07 11:33:01

How to move filters from gridview to a separate form?

There is a gridview, it has filters. One of the filters by date, you need to make this filter as a period, that is - "from - to", since the column is narrow in width, then as a decision to put this filter in front of the grid itself. The question is, how then to hang the submit event on enter, + so that it is like in one form?

'filterModel' => $searchModel, 
                            'columns' => [
                                [
                                    'attribute' => 'created_at',
                                    'value' => function(Visitors $model) { 
                                        return  $model->getCreated();  
                                    },
                                    'filter' => DateTimePicker::widget([
                                        'name' => 'VisitorsSearch[created_at]',
                                        'options' => ['placeholder' => Yii::t('app', 'SELECT_HINT')],
                                        'convertFormat' => false,
                                        'type' => DateTimePicker::TYPE_INPUT,
                                        'value' => $searchModel->created_at,
                                        'pluginOptions' => [
                                            'format' => 'yyyy-mm-dd hh:ii:ss',
                                            'todayHighlight' => true
                                        ]
                                    ]),                                            
                                ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
matperez, 2017-03-07
@bizzonaru

GridView has a GridView::$filterSelector property, you can enter a css selector into it, which Grid will follow and update when submitting. For example, you can enter something like '#search-form input,#search-from select' there and get the desired behavior.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question