digital-creative/expandable-table-row

为您的资源表格的每一行提供添加额外数据的一种简单方法。

资助包维护!
milewski

安装次数: 7,714

依赖项: 0

建议者: 0

安全性: 0

星标: 14

关注者: 3

分支: 1

公开问题: 2

语言:Vue

v0.2.0 2023-10-25 14:59 UTC

This package is auto-updated.

Last update: 2024-08-28 10:34:16 UTC


README

Latest Version on Packagist Total Downloads License

为您的资源表格的每一行提供添加额外数据的一种简单方法。

安装

您可以通过 composer 安装此包。

composer require digital-creative/expandable-table-row

基本用法

要使用新功能,您只需将 ->expandableRowData() 方法添加到字段定义中,并返回扩展 Nova Field 的任何类或字段数组。

class UserResource extends Resource
{
    public function fields(NovaRequest $request): array
    {
        return [
            //...
            Text::make('First Name')->expandableRowData(function () {
                return [
                    Line::make(null)->displayUsing(fn () => 'Name')->asSubTitle(),
                    Text::make('Full Name', fn (User $user) => sprintf('%s %s',$user->first_name, $user->last_name))->copyable(),
                    Text::make('Email')->copyable(),
                ];
            }),
    
            Text::make('Last Name')->expandableRowData(function () {
                return [
                    Line::make(null)->displayUsing(fn () => 'Address')->asSubTitle(),
                    Text::make('Country'),
                    Text::make('Address', fn (User $user) => sprintf(
                        '%s, %s, %s - %s', $user->city, $user->state, $user->address, $user->zipcode
                    ))->copyable(),
                ];
            }),
            //...          
        ];
    }
}

设置

您可以通过使用 ->expandableRowOptions() 来配置多个选项。下面将解释每个选项。

public function fields(NovaRequest $request): array
{
    return [
        Text::make('...')->expandableRowOptions([
            'span' => 2, // This makes the metadata take X much more columns.
            'expanded_by_default' => true, // This makes the table row start expanded by default.
            'preallocate_column_width' => true, // This will avoid the table column shifting when expanding / collapsing.
        ]),
    ];
}

⭐️ 表达您的支持

如果此项目对您有帮助,请给予 ⭐️ 支持!

您可能还喜欢的其他包

许可

MIT 许可证(MIT)。有关更多信息,请参阅 许可文件