fli - Thursday, July 21, 2011 3:22 PM:
Hi Members,
I wish to set a color for some cells in the main grid. (also for "implementation type = federated" Items properties)
i.e. when: value > 10, the cell should turn blu
So I looked at some code from the "activity2",
I can't make it work for me ?
this fed_css property which is set, is it the style for main-grids-display ?
Is there any documentation ? please help.
BR / Christoffer
Activity2 method, PM_setFedCss_For_ACW onafterGet
Brian - Friday, July 22, 2011 8:34 AM:
Hi Christoffer,
This code when put in a ServerMethod for Part will colour code the State label. onAfterGet event.
Dim i As Integer
For i=0 To Me.getItemCount()-1
Dim bg_color As String
Dim myCss As String
Dim text_color As String = "#000000"
Dim thisItem As Item = Me.getItemByIndex(i)
Dim thisStatus As String = thisItem.getProperty("state","")
'------
Select (thisStatus)
Case "Preliminary","In Review"
bg_color = "#FFFFBB" 'light yellow
Case "Released"
bg_color = "#90EE90" 'light green
Case "Superseded","Obsolete"
bg_color = "#FFBBBB" 'light red
Case Else
bg_color = "" 'none
End Select
If bg_color <> "" Then
myCss = ".state { background-color: " & bg_color & " }"
thisItem.setProperty("css",myCss)
End If
Next i
Return Me
Hope this helps.
Brian.
fli - Tuesday, July 26, 2011 4:03 AM:
Brian,
Thank you,
Can you tell me how to modify the text color aswell ?
Christoffer
Brian - Tuesday, July 26, 2011 5:14 AM:
Hi Christoffer,
This line:
myCss = ".state { background-color: " & bg_color & " }"
sets the CSS up for the field. If you add
Dim font_color As String
font_color = "#0000FF"
myCss = ".state { color: " & font_color & " background-color: " & bg_color & " }"
should give you blue text on whatever the background color is.
Have a look at client/styles/default.css to get an idea for how the CSS is created.
Cheers,
Brian.
fli - Tuesday, July 26, 2011 6:19 AM:
Thanks Brian,
Brian - Tuesday, July 26, 2011 6:53 PM:
I realised that I missed a couple of semi-colons in the statement.
myCss = ".state { background-color: " + bg_color + "; color: " + text_color + "; }"
is what the line should look like.
Cheers,
Brian.
vishal_trivedi - Friday, July 29, 2011 2:21 AM:
Brian,
It's working perfectly.
What to do if i want to change color of whole row of main grid in same case?
Thanks in Advance.
Vishal