Added view button in editor bar

Added view button in editor bar

cmpluscmplus Posts: 60Questions: 13Answers: 0

Add a view details button, I would like to add this button but I haven't been able to do it yet. I'm using yajra datatables with laravel and everything works perfectly but now I would like to add a button to view details. I tried to create a function in the editor file but it doesn't work. How can I add this button?

<?php

namespace App\DataTables\Quadri;

use App\Models\Quadri;
use Illuminate\Database\Eloquent\Model;
use Yajra\DataTables\DataTablesEditor;

class QuadriDataTableEditor extends DataTablesEditor
{
    protected $model = Quadri::class;

    /**
     * Get create action validation rules.
     */
    public function createRules(): array
    {
        return [
            'quadri_name' => 'required:'.$this->resolveModel()->getTable(),
            'description',
        ];
    }

    /**
     * Get edit action validation rules.
     */
    public function editRules(Model $model): array
    {
        return [
            'parent_id',
            'quadri_name',
            'fabbricato_id',
            'quota_id',
            'description',
        ];
    }

    /**
     * Get remove action validation rules.
     */
    public function removeRules(Model $model): array
    {
        return [];
    }

    /**
     * Event hook that is fired after `creating` and `updating` hooks, but before
     * the model is saved to the database.
     */
    public function saving(Model $model, array $data): array
    {
        // Before saving the model, hash the password.
        return $data;
    }

    /**
     * Event hook that is fired after `created` and `updated` events.
     */
    public function saved(Model $model, array $data): Model
    {
        // do something after saving the model

        return $model;
    }
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin

    Sorry, I'm not clear on where you want the view details button. Along side the create / edit / delete buttons? Use a custom button for that.

    Allan

  • cmpluscmplus Posts: 60Questions: 13Answers: 0

    I would like to insert a button to see the details, I have only included some columns in the table and I would like to have a button that when I select the row I can see the details and open a modal to view all the information

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin

    I'm still not understanding where you want the button - sorry. Can you use a screenshot and a paint program to illustrate where you want it?

    Thanks,
    Allan

  • kthorngrenkthorngren Posts: 21,083Questions: 26Answers: 4,908

    I'm not sure what exactly you are asking for either. This example show one way a button can be displayed in the row using defaultContent. It has event handlers for the buttons which get the row data using row().data(). You can add code to display this data in a modal.

    Is this what you are looking for?

    Kevin

  • cmpluscmplus Posts: 60Questions: 13Answers: 0

    Sorry, I'm also not very clear on how to do what I would like to do, I'm trying to insert a button in the button bar where I have the new, edit, export buttons, I would like to create a button that when I select a row of the table I see the details , instead of opening a new page I would like to open a modal to see the details of the selected row.
    For example, if I click on the edit button, when I select a row the modal opens and I modify the values entered, I would also like to have a details button to see the values of the row without modifying only the display, I have a table with many columns and I have excluded from the table but I would like to give you the opportunity to see them when you click details

  • allanallan Posts: 62,990Questions: 1Answers: 10,367 Site admin
    Answer ✓

    That sounds like the custom button I mentioned before. Define the button so that its action will open a modal. Use row().data() to get the data for the selected row. See this section of the manual for mode details.

    Allan

  • cmpluscmplus Posts: 60Questions: 13Answers: 0

    Thanks for the help, I'll try to do it now

Sign In or Register to comment.