2017-06-29 34 views

回答

1

理論上你可以創建一個新的類擴展ActionColumn類是這樣的:

namespace app\components; 

use yii\grid\ActionColumn; 
use yii\helpers\Html; 

class MyActionColumn extends ActionColumn 
{ 

    /** 
    * @inheritdoc 
    */ 
    protected function renderFilterCellContent() 
    { 
     return Html::button('Clear Filter'); 
    } 

} 

然後你就可以使用這個類在列定義是這樣的:

'class' => 'app\components\MyActionColumn'

這會將您的按鈕添加到您使用此新類的每一列。

顯然,您可以添加更多功能並進一步對其進行自定義。

希望它有幫助...