backend.list.extendColumns

Provides an opportunity to modify the columns of a List widget

Example usage:

Event::listen('backend.list.extendColumns', function ($listWidget) {
    // Only for the User controller
    if (!$listWidget->getController() instanceof \Backend\Controllers\Users) {
        return;
    }

    // Only for the User model
    if (!$listWidget->model instanceof \Backend\Models\User) {
        return;
    }

    // Add an extra birthday column
    $listWidget->addColumns([
        'birthday' => [
            'label' => 'Birthday'
        ]
    ]);

    // Remove a Surname column
    $listWidget->removeColumn('surname');
});

Or

$listWidget->bindEvent('list.extendColumns', function () use ($listWidget) {
    // Only for the User controller
    if (!$listWidget->getController() instanceof \Backend\Controllers\Users) {
        return;
    }

    // Only for the User model
    if (!$listWidget->model instanceof \Backend\Models\User) {
        return;
    }

    // Add an extra birthday column
    $listWidget->addColumns([
        'birthday' => [
            'label' => 'Birthday'
        ]
    ]);

    // Remove a Surname column
    $listWidget->removeColumn('surname');
});

Usage

Triggers

Class or file Line
Backend\Widgets\Lists 906
Copyright © 2024 Winter CMS