Laravel-Backpack / CRUD

Build custom admin panels. Fast!
https://backpackforlaravel.com
MIT License
3k stars 880 forks source link

[New Widget] Table Widget #5523

Open karandatwani92 opened 1 month ago

karandatwani92 commented 1 month ago

WHY

Why not? Screenshot 2024-05-17 at 4 29 04 PM

How to use

Widget::make([
    'type'        => 'table',
    'wrapperClass' => 'col-md-6',
    //'height' => '550px',
    'class' => 'table table-hover',
    'content' => [
        'header' => 'Sales Report 2024',
        'thead' => ['Month', 'Sales', 'Expenses', 'Net Income'],
        'tbody' => [
            ['January 2024', '$100,000', '$50,000', '$50,000'],
            ['February 2024', [
                'value' => '120,000',
                'prefix' => '$',
                'suffix' => '*',
                'limit' => 10,
                'wrapper' => [
                    'element' => 'a',
                    'class' => 'text-success fw-bold',
                    'href' => url('something'),
                    'target' => '_blank',
                    'title' => 'Send a new email to this user',
                ]
            ], '$60,000', '$60,000'],
            ['March 2024', '$130,000', '$70,000', '$60,000'],
            ['April 2024', '$140,000', '$80,000', '$60,000'],
            ['May 2024', '$150,000', '$90,000', '$60,000'],
            ['June 2024', '$160,000', '$100,000', '$60,000'],
            ['July 2024', '$170,000', '$110,000', '$60,000'],
            ['August 2024', '$180,000', '$120,000', '$60,000'],
            ['September 2024', '$190,000', '$130,000', '$60,000'],
            ['October 2024', '$200,000', '$140,000', '$60,000'],
            ['November 2024', '$210,000', '$150,000', '$60,000'],
            ['December 2024', '$220,000', '$160,000', '$60,000'],
        ],
        'tfoot' => ['Month', 'Sales', 'Expenses', 'Net Income'],
    ],
])->onlyHere()
ziming commented 3 weeks ago

looks great! does the table widget support actions & pagination?

karandatwani92 commented 3 weeks ago

Hey @ziming

Sorry, It's a simple table widget. One can set up link buttons using the wrapper for now. When I submitted this PR, I was building reports using widgets in one of my projects and i needed a static table.

When I showed this small PR to the Backpack team. They told me the same as you asked... They said, People will ask for pagination & actions. 😀

Let's see how it goes.