Sometimes we need fill color or change text color to emphasize particular information. For example, if states of documents have different colors, users will be easier to identify information that they need, like below picture:
There is a system property named "css" which could store item's style, but how to assign the style to property? The only thing we need to do is specify property name as a CSS class.
Here is an example to show how dynamically assign above style:
Create a method with above code, and then add with Server Event "onAfterGet" into ItemType that you want. Here we take "Document" as example.
Now we can see states of documents with color while searching "Document".
There is a system property named "css" which could store item's style, but how to assign the style to property? The only thing we need to do is specify property name as a CSS class.
.state {
background-color: #B3FF99;
}
Here is an example to show how dynamically assign above style:
Dim objItem As Item
Dim strState As String
Dim strColor As String
For i As Integer = 0 To Me.getItemCount()-1
objItem = Me.getItemByIndex(i)
strState = objItem.getProperty("state","")
Select strState
Case "Released"
strColor = "#B3FF99"
Case "Preliminary"
strColor = "#FFFF99"
Case Else
strColor = "#fff"
End Select
objItem.setProperty("css", ".state { background-color: " & strColor & " }")
Next
Return Me
Create a method with above code, and then add with Server Event "onAfterGet" into ItemType that you want. Here we take "Document" as example.
Now we can see states of documents with color while searching "Document".
Comments
Post a Comment