Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit and delete actions button each row #377

Open
red8001 opened this issue Jan 9, 2022 · 5 comments
Open

edit and delete actions button each row #377

red8001 opened this issue Jan 9, 2022 · 5 comments

Comments

@red8001
Copy link

red8001 commented Jan 9, 2022

hi
please can you help me how to add an editable row in datatable, i tried for myself to add a simple colum with action button but nothing working
thanks for the help.

@rikthomas
Copy link
Collaborator

If you have declared a builder() method but no $public property, the model is returned as null and the delete method fails.

The workaround is to declare both a public property and builder method:

public $model = User::class

public function builder()
    {
        return User::where('hospital_id', Auth::user()->id);
    }

I have submitted a PR (#379) with a fix

@red8001
Copy link
Author

red8001 commented Jan 10, 2022

thanks yout for responding
but i did not understand the goal here its to add an edit and delete button for each row
image
so any idea ????

@red8001 red8001 changed the title edit and delete actions button edit and delete actions button each row Jan 10, 2022
@rikthomas
Copy link
Collaborator

If you use the editable() method, it replaces that cell with a view that contains and Alpine/Livewire component where you can edit the data inline by clicking on the cell.

What do you want the edit button to do? If you want it to open a modal where the whole row is editable or make all the cells in the row editable, I think you will need to make your own custom view or callback.

@red8001
Copy link
Author

red8001 commented Jan 11, 2022

thanks for responding
according to my project i need edit button to open a modal with all information about this row, editable method dont work for me as i want i fixed part of the problem in the controller i add a column to return a button like :
Column::callback(['id'], function ($id) {
return "<button wire.click='showeditModal($id)' class='bg-white rounded-md p-2 inline-flex items-center justify-center text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-indigo-500'>Edit";
})->label('Actions'),
but the button dont show the model in my livewire componnent that second part of the problem
how your apporach??
thanks

@rikthomas
Copy link
Collaborator

I've done this on a project. The approach I took was to make a custom view and then insert a Livewire component within that view with my modal and editable fields. I ended up with a simple custom view containing my component like this:

<div class="flex-1 flex justify-center">
    <livewire:update-ticket :ticket_id="$row->id" :key="$row->id">
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants