Skip to content

Setting cell background color #975

Closed Answered by lrljoe
thefireescaper asked this question in Q&A
Discussion options

You must be logged in to vote

What's the criteria for setting the background colour?

Please see the below, which would set the background of a field "total" to red if the value was less than "< 1000"

If this doesn't make sense, then please give a use case and I'll try to help give you a pointer. The docs here:

https://rappasoft.com/docs/laravel-livewire-tables/v2/datatable/available-methods

Really do cover a lot of it though!

public function configure(): void
{
  // Takes a callback that gives you the current column, row, column index, and row index
  $this->setTdAttributes(function(Column $column, $row, $columnIndex, $rowIndex) {
    if ($column->isField('total') && $row->total < 1000) {
      return [
        'clas…

Replies: 1 comment

Comment options

lrljoe
Dec 29, 2022
Collaborator Sponsor

You must be logged in to vote
0 replies
Answer selected by lrljoe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants