Dynamic Styling group of rows in Grid

I’ve a grid which has multiple rows. The rows would have a column named GUI_ID and they’re common for a set of rows. How can I style them ? This GUI_ID are actually UUIDs.

In the example provided

 grid.setClassNameGenerator(person -> {
            if (person.getRating() >= 8)
                return "high-rating";
            if (person.getRating() <= 4)
                return "low-rating";
            return null;
        });

it is looking for a static value. But in my case, they’re dynamic

You mean you want to replace the 8 and the 4 with something dynamic?

If so, you could e.g. define a method like int getHigh() and so on

Yes the values are dynamic and I cannot predict what those values could be. The values are actually UUIDs

Yes so you can use any Java mechanics to get the comparison value. It doesn’t need to be hardcoded.

yes yours is giving me some clue

but my doubt is, how can I say UUID 123 use RED and UUID 456 use Green as I do not know the values in advance.

Yes, how do you know which color matches which UUID

it could be any random color for each set of UUIDs. This is just to let the user know they’re one set

Yes, so how do you know a uuid belongs to a set?

You could have something like this:

grid.setClassNameGenerator(uuid -> {
   String setForUuid = getSetForUuid(uuid);
   String className = getClassNameForSet(setForUuid);
   return className;
}

// later:
String getSetForUuid(UUID uuid) {
  if (uuid.equals(123)) {
     return "SET 1";
  } else {
     return null;
  }
}

String getClassNameForSet(String set) {
   if ("SET 1".equals(set)) {
     return "red";
   } else {
     return null;
   }
}

thanks, Let me try this

Each row has a UUID and each set of rows have same UUID

I see, here also we’re looking for static value 123 to compare

so this approach is not working. Seems it is a complicated requirement

Sounds to me like that you’ll need to generate color values based on those UUIDs.

Or, rather, if you want to use ClassNameGenerator specifically, you’ll need to define a finite number of css classes use certain colors, and somehow assign those classes based on the UUID.

The problem with that is that you probably don’t want adjacent groups to be assigned the same classname