How to stop table refreshing when using a ToggleColumn?
I have a table that is a little show to load, 3-4s. We use the deferLoading method and is ok for now while we work on some database design issues. There are a few Toggle Columns, however when clicked there is a 3-4s delay as the table refreshes. Is there anyway to stop the table refreshing when the toggle state changes?
6 Replies
it shouldnt be a 3-4s delay. I suspect this is down to your code, do you have debugbar enabled for instance....
That wasn't the question 😅
You could try to overwrite the
updateTableColumnState()
method and add a ->skipRender()
:
That stops the table from refreshing, except the toggle button doesn't then re-render 😦 Strangely it will toggle off, but not on. The state will update however
That’s how livewire works. It needs updated state to re-render.
Your best bet is to add alpine based extractAttributes to optimistically handle the UI. But that seems like more trouble than it’s worth.
It shouldn’t take 3-5 seconds to update and re-render unless your table is just unnecessarily large from an html pov or there’s a database / processing issue.
except the toggle button doesn't then re-renderI hoped that the state is already adjusted on client side so it doesn't need a rerender.
It's a large dataset. Seems to be some workaround in the toggle-column " // The state is only updated on the frontend if the toggle is
// being turned off, so we only need to reset it then."
Table is paginated, so shouldn't be a problem
So I managed to get this working by updating the alpine js on the toggle-column.blade.php file to update the state when toogle on as well as off. Thanks for your help here guys 🙂