backend.list.extendColumns

Triggered in Backend\Widgets\Lists.

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');
});