Filters in GridView

GridView has a core feature of being able to simplify filter rows just by putting an additional row below the header row.

Filters are mainly text input but in general they can be any type of control and we can customize them as much as we want.

Filters can be activated by filling out the GridView widget property filterModel with an instance of the model class and automatically a new row will be created below the header, containing working text inputs.

Filter text inputs have a name attribute filled with the model class name, which includes the field name. In this way, we will pass data to a controller, including everything in a single array; a variable that can easily be used to populate a search model massively.

Note

Automatic ...

Get Yii2 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.