F
Filamentβ€’2y ago
bionary

show/hide reorder based on conditions?

Reordering a table seemed amazing until I realized I'm working with a table with ~5000 rows ...it hangs up and goes kaboom unless a filter that limits the data is applied. I'd love to be able to enforce that practice with end users. I was thinking that maybe conditionally showing the reorder icon only when a filter is present would be a potential solution. But reorderable() only accepts string input. 😦 Any advice for working with sortable rows with large data sets?
7 Replies
Mohamed Melouk
Mohamed Meloukβ€’2y ago
Reordering disable pagination by default. you can change this behaviour by using
protected function isTablePaginationEnabledWhileReordering(): bool
{
return true;
}
protected function isTablePaginationEnabledWhileReordering(): bool
{
return true;
}
combine that with
protected function getTableRecordsPerPageSelectOptions(): array
{
return [10, 25, 50];
}
protected function getTableRecordsPerPageSelectOptions(): array
{
return [10, 25, 50];
}
forces the user to reorder on max 50 record per page that solved it for me
bionary
bionaryOPβ€’2y ago
first off, thank you. the reordering is strange but I think that's a bit innate. when isTablePaginationEnabledWhileReordering90 == true it leaves many duplicate order numbers (as expected) I don't think that's optimal for my use case. I really don't mind the default reordering IF I could somehow enforce filtering. I'm hoping there is a way to only allow reordering if a filter is applied. The reason is, once a filter is applied the data count gets cut down to < 2% of the total and reordering works quite nicely.
Dan Harrin
Dan Harrinβ€’2y ago
i really dont think you should use drag and drop reordering for 5000 rows thats not a good UX for your users regardless of the performance maybe just add action buttons to each row that can move a row up or down the list, that way you preserve pagination too
toeknee
toekneeβ€’2y ago
+1 for Dan's comment, you are asking for a hell of a lot on the browser too. Lesser computers will struggle too.
bionary
bionaryOPβ€’2y ago
I agree. That's why I would like to enforce a filter before enabling drop reordering? Most of filament has closures for allowing conditionals. A simple example is ->hidden(...) etc... Is there a way to show/hide drag-reordering based on a filter condition?
ZedoX
ZedoXβ€’2y ago
protected function isTableReorderable(): bool
{
return // check if filter applied $this->tableFilters
}
protected function isTableReorderable(): bool
{
return // check if filter applied $this->tableFilters
}
bionary
bionaryOPβ€’2y ago
oh nice...I'll give this a try later. Thank you. not sure why but phpstorm's auto-fill-a-function has not been finding methods lately.
Want results from more Discord servers?
Add your server