Widget order on a panel
Any pointers on how to change the order of widgets in a panel? I've tried changing the order in the panel provider, changing the sort attribute inside widget, but it doesn't seem to work.
Any help here is appreciated!
9 Replies
try in the widgets to do:
protected static ?int $sort = 0;
protected static ?int $sort = 1;
etc
Setting the $sort inside the widget class worked for my widgets https://filamentphp.com/docs/3.x/panels/dashboard#sorting-widgets
First one has sort set to 1, Hello World widget's sorting is 3 and the third widget here has sorting 2. And in the panel they are included in the same order.
Another odd thing here is the double spacing in the grid here. And no, I don't use autodiscovery / load from path.
Another odd thing here is the double spacing in the grid here. And no, I don't use autodiscovery / load from path.
Here, using the Filament Demo repo:
https://github.com/filamentphp/demo/tree/main/app/Filament/Widgets
GitHub
demo/app/Filament/Widgets at main · filamentphp/demo
Source code for the demo.filamentphp.com website. Contribute to filamentphp/demo development by creating an account on GitHub.
The default sort shows up this way:
But then simply editing the $sort on the first 3 widgets:
results in the new order in the dashboard:
Thank you so much for your help! This was entirely my own stupidity; I had to include the "dashboard" using render hook as passing main page javascript to widgets turned out to be little problematic. Trying to get around this by using "panels::page.footer-widgets.before" render hook. Unfortunately:
Inside the Dashboard.php page results in "Unable to find component: [app.filament.widgets.footer-widget]". This happens even if I have nothing defined inside the widget. Maybe I'm again misunderstanding something?
Did you create both the widget component PHP class and the corresponding blade file for it?