Inline Edit
The data table has a number of methods to help you edit the data directly in the table.
Note: For each column edit setting, you need to have a corresponding field in the form.
Editable
With the editable method, you can click on the data in the table and edit the saved data in the pop-up dialog box.
Text input
$grid->column('title')->editable();Textarea input
$grid->column('title')->editable('textarea');Select
The second parameter is the option selected by select
$grid->column('title')->editable('select', [1 => 'option1', 2 => 'option2', 3 => 'option3']);Date selection
$grid->column('birth')->editable('date');Date and time selection
$grid->column('published_at')->editable('datetime');Year selection
$grid->column('year')->editable('year');Month selection
$grid->column('month')->editable('month');Day selection
$grid->column('day')->editable('day');Switch
Note: In the
grid, set aswitchfor a field, and you need to set the sameswitchfor the field inform.
Quickly turn the column into a switch component, using the following:
$grid->('status')->switch();
// set text, color, and stored values
$states = [
'on' => ['value' => 1, 'text' => 'open', 'color' => 'primary'],
'off' => ['value' => 2, 'text' => 'close', 'color' => 'default'],
];
$grid->column('status')->switch($states);Switch group
Note:
switchis set for some fields ingrid, and the sameswitchshould be set for these fields inform.
Quickly turn the column into a switch component group, using the following:
$states = [
'on' => ['text' => 'YES'],
'off' => ['text' => 'NO'],
];
$grid->column('switch_group')->switchGroup([
'hot' => 'hot',
'new' => 'latest'
'recommend' => 'recommended',
], $states);Radio
Set the column to the radio component and set the same radio for these fields in the form method.
$grid->column('options')->radio([
1 => 'Sed ut perspiciatis unde omni',
2 => 'voluptatem accusantium doloremque',
3 => 'dicta sunt explicabo',
4 => 'laudantium, totam rem aperiam',
]);Checkbox
Set this column to the checkbox component and also set the same checkbox for these fields in the form method.
$grid->column('options')->checkbox([
1 => 'Sed ut perspiciatis unde omni',
2 => 'voluptatem accusantium doloremque',
3 => 'dicta sunt explicabo',
4 => 'laudantium, totam rem aperiam',
]);Last updated