Get current table data for widget
Hi,
I'm using a widget on a view page with a table and need the widget to access the current data in the table. I've followed the instructions here https://filamentphp.com/docs/3.x/panels/resources/widgets#accessing-page-table-data-in-the-widget and it works when the page first loads but when you filter or change page the widget still seems to be getting the old data.
The widget view uses javascript which needs to rerun with the new data. I've got this bit of code in the blade file which I'm not sure is the best way to rerun the javascript but it works (the javascript is rerunning but recieving the old data):
Then within the loadData function I have this javascript to get the new data:
And this is the widget file
But every time its called the
I'm using a widget on a view page with a table and need the widget to access the current data in the table. I've followed the instructions here https://filamentphp.com/docs/3.x/panels/resources/widgets#accessing-page-table-data-in-the-widget and it works when the page first loads but when you filter or change page the widget still seems to be getting the old data.
The widget view uses javascript which needs to rerun with the new data. I've got this bit of code in the blade file which I'm not sure is the best way to rerun the javascript but it works (the javascript is rerunning but recieving the old data):
{{$this->js('loadData()');}}Then within the loadData function I have this javascript to get the new data:
var all = {{ $this->all() }};And this is the widget file
But every time its called the
$this->getPageTableRecords()->toJson() seems to return the data of the original page you start on rather than the current page or filtered data