Just a few weeks ago I stumbled upon a property in KTM I wasn’t aware of: table cells can have their background colour changed! That’s not only fancy but in fact very useful to point out certain facts to the user. Imagine negative and positive amounts: the small sign sometimes is hard to recognise, especially as Kofax still does not provide us with a way to properly justify items in validation.
So, why not use colours? Orange represents something warm and positive, while blue rather represents something cool, so the opposite: a negative amount. As such, using those two colours for the background seems reasonable. Of course you’re not restricted to amounts: the below picture shows a table where Yes has been highlighted in blue, and No in orange.
You can of course do more than that. Think about invoice processing where you highlight those rows of items that could not be matched to a PO, or anything else that requires a persons attention.
Note that the colour is set on the ValidationForm.Table object, while the colour usually is related to a content of a cell object that’s part of a field. So colouring must happen in an appropriate event. Fortunately KTM makes sure both objects are synchronised: so if you’d delete a row in validation, the respective row within the table object of the field also is deleted.
Here’s some code to get you started:
Private Sub ValidationForm_DocumentLoaded(ByVal pXDoc As CASCADELib.CscXDocument)
' colouring the table here
ValidationFormTable_ColourCellBasedOnContent(ValidationForm.Tables.ItemByName("Table"), pXDoc.Fields.ItemByName("Table").Table, "Yes", 2, 30, 144, 255)
ValidationFormTable_ColourCellBasedOnContent(ValidationForm.Tables.ItemByName("Table"), pXDoc.Fields.ItemByName("Table").Table, "Yes", 3, 30, 144, 255)
ValidationFormTable_ColourCellBasedOnContent(ValidationForm.Tables.ItemByName("Table"), pXDoc.Fields.ItemByName("Table").Table, "No", 4, 255, 165, 0)
End Sub
Private Sub ValidationFormTable_ColourCellBasedOnContent(valTable As CscScriptValidationTable, fieldTable As CscXDocTable, cellContentToMatch As String, cellIdx As Long, colourRed As Long, colourGreen As Long, colourBlue As Long)
Dim r As Long
For r = 0 To valTable.Rows.Count - 1
If fieldTable.Rows(r).Cells(cellIdx).Text = cellContentToMatch Then
' content does match, so colour the cell
valTable.Rows(r).Cells(cellIdx).SetBackColor(colourRed, colourGreen, colourBlue)
End If
Next
End Sub