MedicOneSystems / livewire-datatables

Advanced datatables using Laravel, Livewire, Tailwind CSS and Alpine JS
https://livewire-datatables.com/
MIT License
1.19k stars 259 forks source link

how to send data to a view without callback() #454

Closed insulae closed 2 years ago

insulae commented 2 years ago

I have this column:

Column::raw('@row:=@row + 1 AS num')
->defaultSort('asc')
->view('_tbl.extra')
->label('Num'),

I want to send extra data to the view (in this case the name of a modal) I cant use callback (I think) because I need to use ::raw

how can I do this? or an alternative to this:

Column::raw('@row:=@row + 1 AS num')
->defaultSort('asc')
->view('_tbl.extra', ["modal" => "modalToUse"])
->label('Num'),
thyseus commented 2 years ago

I had the same problem and i have implemented a little fix to exact this problem in the near future and link it to here.

insulae commented 2 years ago

Excellent, thanks in advance!

thyseus commented 2 years ago

Could you please confirm if https://github.com/MedicOneSystems/livewire-datatables/pull/455 solves your issue ? thanks !

insulae commented 2 years ago

I downloaded the version: https://github.com/MedicOneSystems/livewire-datatables/tree/454-pass-params-to-render but I have the error: Cannot use array as default value for parameter $data of type Illuminate\Contracts\Support\Arrayable

in your code you have: public function view($view, Arrayable $data = [])

I tried to figure out how to use the "Arrayable" and i didn't find. So I remove the Arrayable and it's work.

Removing the Arrayable from Column.php: public function view($view, $data = [])

I can do and work as expected : ->view('_tbl.extra', ["modal" => "myModal"])

You must confirm now if I am using wrong or if that Arrayable shouldn't go (I'm not very experienced)

thyseus commented 2 years ago

You are totally right; the type hint is not necessary. I will remove the type hint and merge the feature tomorrow when i am in office.