Maslosoft Framework Documentation
Flexible Application Foundation
Overriding Renderer
To override renderer per grid instance, it is possible to set different rendering class for each of the columns.
To define custom renderer, column definition should be extended
to array with required class
parameter and
any parameters available for particular renderer.
Example of editable fields
In this example user lastName
is rendered
by EditableText
, while by default it would render with
Data
.
Default renderer can be defined on model with @GridRenderer
annotation.
Click on any of names of "Last name" column, it is now editable.
First name | Last name | Activated | |
---|---|---|---|
Notice the second column definition, that contains
array with class
and name
values.
echo GridView::widget([ 'dataProvider' => new DataProvider(new ExampleUser(), [ 'pagination' => [ 'size' => 10 ] ]), 'columns' => [ 'firstName', [ 'class' => EditableText::class, 'name' => 'lastName', ], 'email', 'active' ] ]);