Bootstrap datatable row colour

I got the row colours working correctly using the classes. However, this is not practical for my app as i need to colour rows based on different groups and the colours are selected by the users and there can be many groups.

Can i create colour classes when i fill the grid for the numerous groups or is there some other way to colour the row?

Thanks