Reputation: 846
Currently there is no filter property in the Yii 2.0's actionColumn class, meaning you can not add content to the filter cell.
How can I extend the yii\grid\actionColumn class and add the filter property functionality that is in the yii\grid\column class so I can move my clear-filter button from the header to filter cell?
Upvotes: 2
Views: 1815
Reputation: 859
In theory you can just create a new class extending the ActionColumn
class like this:
namespace app\components;
use yii\grid\ActionColumn;
use yii\helpers\Html;
class MyActionColumn extends ActionColumn
{
/**
* @inheritdoc
*/
protected function renderFilterCellContent()
{
return Html::button('Clear Filter');
}
}
Then you can use this class in your column definition like this:
'class' => 'app\components\MyActionColumn'
which will add your button to every column where you are using this new class.
Obviously you can add a lot more functionality and customise it even further.
Hope it helps...
Upvotes: 3