Change backgrund color of row in setupListOperation ? #753
-
How can I change the background color of a row based on a variable (setupListOperation)? For example, in a table, I have orders/rides that I need to assign to drivers. When I send a ride, the background of that row should be yellow. Is it possible to change the background color of a row? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hello, I would just add some Some pseudo-quasi-working code: CRUD::column('my_column')->wrapper(['my-custom-attribute' => fn($crud, $column, $entry, $related_key) => $entry->active ? 'true' : 'false']); const rows = document.querySelectorAll('[my-custom-attribute="true"]');
for (const row of rows) {
row.classList.add('bg-danger');
} Cheers |
Beta Was this translation helpful? Give feedback.
-
It's not a "full" solution, but it's a good one as I see you already have colors 😄 You need to probably hook to the datatables draw event, and everytime the table finishes drawing you apply the colors, something like:
You can find some examples in our codebase. Let me know how it goes. 🙏 |
Beta Was this translation helpful? Give feedback.
Sure, just put that sent value in a wrapper attribute like I suggested.
You will endup with a
my-custom-attribute="red/yellow/green"
in your column wrapper.Search those and apply that color to the tr.
Cheers