fgh151/yii2-grid

Grid view with switchable columns

Maintainers

Package info

github.com/fgh151/yii2-grid

Type:yii2-extension

pkg:composer/fgh151/yii2-grid

Transparency log

Statistics

Installs: 7

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.5 2026-08-24 09:55 UTC

This package is auto-updated.

Last update: 2026-08-24 09:56:21 UTC


README

Grid view with swithcable columns

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist fgh151/yii2-grid "*"

or add

"fgh151/yii2-grid": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

use fgh151\yii\grid\GridView;

/**
 * @var $dataProvider yii\data\ActiveDataProvider
 * @var $searchModel \yii\db\ActiveRecord
 */

$availableColumns = ['id', 'email', 'firstname', 'lastname'];
$defaultColumns = ['id', 'email'];

echo GridView::widget([
        'dataProvider' => $dataProvider, // required
        'filterModel' => $searchModel, // default is null
        'defaultColumns' => $defaultColumns, // default is [], if you want to use default columns
        'availableColumns' => $availableColumns, // default is [], if you want to use default columns
]);

Trim column header

$availableColumns = [
    [
        // Default column header will be 'Column with long attribute label'
        // Or fetch from $model->getAttributeLabel('attribute')
        'attribute' => 'column_with_long_attribute_label',
        // Now it will be 'Column with...'
        'trim' => 10,
    ],
];