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
toeknee
toeknee5d ago
it shouldnt be a 3-4s delay. I suspect this is down to your code, do you have debugbar enabled for instance....
Dennis Koch
Dennis Koch5d ago
That wasn't the question 😅 You could try to overwrite the updateTableColumnState() method and add a ->skipRender():
public function updateTableColumnState(string $column, string $record, mixed $input): mixed
{
$this->skipRender();
return parent::updateTableColumnState($column, $record, $input);
}
public function updateTableColumnState(string $column, string $record, mixed $input): mixed
{
$this->skipRender();
return parent::updateTableColumnState($column, $record, $input);
}
andrewdrake
andrewdrakeOP5d ago
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
awcodes
awcodes5d ago
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.
Dennis Koch
Dennis Koch5d ago
except the toggle button doesn't then re-render
I hoped that the state is already adjusted on client side so it doesn't need a rerender.
andrewdrake
andrewdrakeOP4d ago
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 🙂

Did you find this page helpful?