The text becomes white because the highlight color is too dark and therefore the LAF will switch the text from black to white.
You could of course use a lighter row color to work around this problem but that is a workaround.
Since a couple of versions in Servoy the rowBGCcolorCalculation event will pass the type of object a column is so you can act accordingly. So we could have a method that would give a different row color back when the element is a button or a combobox.
The following method does exactly that.
- Code: Select all
/**
* Calculate the row background color.
*
* @param {Number} index row index
* @param {Boolean} selected is the row selected
* @param {String} elementType element type
* @param {String} dataProviderID element data provider
* @param {String} formName form name
* @param {JSRecord} record selected record
* @param {Boolean} edited is the record edited
*
* @returns {Color} row background color
*
*/
function calculateRowBGColor(index, selected, elementType, dataProviderID, formName, record, edited) {
var color = "#FFFFFF";
if ( selected ) {
// The selected row
if ( edited ) {
color = "#ffffff"; // field is edited, use your favorite editable field background color
} else if ( application.getOSName() == "Mac OS X" &&
forms[formName].controller.view == 3 &&
(elementType == "COMBOBOX" || elementType == "BUTTON") ) {
color = "#FFFFFF"; // or use your favorite (light) color that keeps the combobox/button text black and readable.
} else {
color = "#0000FF"; // or use your favorite highlight color
}
} else if ( index%2 == 0 ) {
// even row color
color = "#EDF3FE";
// odd row will use the standard color defined at the top of this method
}
return color;
}
You can simply attach this global method to any (listview/tableview) form in your solution that you want to use it on.
The code will know if the form is a table view or not so it will only apply the exception on table views.
It will also know if you are on a Mac so other platforms won't see this behavior.
This is the result:
And here when you edit a field:
Enjoy!