Archive

Archive for January 21st, 2010

Dynamic change color on a row of grid, based on some cell value

January 21st, 2010 2 comments

This is considered by some people as Holy Grail of Syteline Form Personalization.

Here is what we want to do.  In “Time Phased Inventory” form, we want to change the color to yellow for those rows that is PO.

First, we need to create a new form script method, called SetPOColor()

Sub SetPOColor()
Dim i as Integer
Dim j as Integer
Dim sReference As String
Dim sRef3 As String
Dim sRef4 As String
Dim oSupDem As IWSIDOCollection

oSupDem = ThisForm.PrimaryIDOCollection.GetSubCollection(“SLSupDems”, -1)
j = oSupDem.GetNumEntries

‘    MsgBox(“j = ” + CStr(j))

For i = 1 To j

sReference = ThisForm.Components(“SLSupDemsGrid”).GetGridValueByColumnName(i, “SLSupDemsReferenceSubGridCol”)

sRef3 = Mid(sReference, 1, 3)
sRef4 = Mid(sReference, 1, 4)
If sRef3 = “PO ” Or sRef4 = “XPO ” Then
ThisForm.Components(“SLSupDemsGrid”).SetGridRowColColor(i, 0, “255,255,0”, “”)
End If
Next i
ThisForm.Components(“SLSupDemsGrid”).ForceRepaint
End Sub

Secondly, we create a new event handler for event “StdObjectSelectCurrentCompleted”, to call the above form script method SetPOColor().

Done.  Now here we are: