RowColor — table row coloring
Entities can implement the RowColorProvider interface to control the background color of their rows in the portal table. The framework automatically attaches the color as a _rowColor field in entity data.
enum class RowColor {
NONE, SUCCESS, WARNING, DANGER, INFO, MUTED
}
interface RowColorProvider {
fun currentStatus(): RowColor?
}Color mapping
| Value | Color | CSS class |
|---|---|---|
NONE | — (default) | none |
SUCCESS | green | qp-tr-success |
WARNING | yellow | qp-tr-warning |
DANGER | red | qp-tr-danger |
INFO | blue | qp-tr-info |
MUTED | gray | qp-tr-muted |
Implementation
@Entity
@Table(name = "task_run")
@PortalEntity(label = "Task Runs", module = "System")
class TaskRun : RowColorProvider {
@Column(length = 20)
@Enumerated(EnumType.STRING)
@PortalField(
label = "Status", order = 2,
renderer = RendererType.SELECT,
selectEnum = TaskRunStatus::class
)
var status: TaskRunStatus = TaskRunStatus.RUNNING
override fun currentStatus(): RowColor? = when (status) {
TaskRunStatus.RUNNING -> RowColor.INFO // blue — in progress
TaskRunStatus.COMPLETED -> RowColor.SUCCESS // green — success
TaskRunStatus.ERROR -> RowColor.DANGER // red — error
TaskRunStatus.CANCELLED -> RowColor.WARNING // yellow — cancelled
}
}
nullreturned bycurrentStatus()is equivalent toRowColor.NONE— no row coloring applied.
Last updated on