Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Carl-Tabuso's avatar

Rappasoft livewire table

Newbie on livewire here. Can anybody give me an idea on how to dispatch a select filter event from one table to another. Imagine a scenario where you have a row on your first table that holds the value of some date range. What you want to do upon clicking the row on is to dispatch an event and navigate (using wire:navigate) to the next table with date range filter applied based on which row you clicked on.

Do i have to like bind a table row like:

        $this->setTrAttributes(function ($row, $index) {
            return [
                'wire:click' => "\$dispatchTo(
                    'second-datatable-component', 
                    'event-name', 
                    { range: $row->daterange})",
            ];
        });

Any response would be appreciated.

0 likes
2 replies
JeffreyW's avatar

You can attach the wire:click event to the row, but instead of directly dispatching it to another component, you can use $dispatchTo with the correct component ID and pass the data (like the date range) you want to share.

Handling the event in the second table (receiver component): In the second table, you'll listen for the event and apply the date filter using the passed data.

1 like
Carl-Tabuso's avatar

Appreciated the response, but what i did is simply write a url query params and pass that to the clickable row that will bring me to the next table. The date range is then automatically applied on navigate based on the query string.

		// this ugly af
        $this->setPrimaryKey('overtime_id')
            ->setTableRowUrl(function ($row) {
                $cutOffFilter = [
                    'start' => Carbon::parse($row->payroll->cut_off_start)->format('Y-m-d'),
                    'end' => Carbon::parse($row->payroll->cut_off_end)->format('Y-m-d'),
                ];

                $filterParams = $this->buildDateRangeFilterParams($cutOffFilter);

                \Log::info('cutoff filter: ', [$filterParams]);
                
                return route($this->routePrefix.'.overtimes.requests').'?'.
                    http_build_query($filterParams);
            })
            ->setTableRowUrlTarget(fn () => 'navigate');

Please or to participate in this conversation.