Jan,
Is it possible to access report fields from the broker in order to set their background color or other visual properties?
Thank you,
Igal
Changing field colors through broker
-
- Site Admin
- Posts:110
- Joined:Sun Jul 18, 2010 5:21 pm
- Location:Aalst, Belgium
- Contact:
Re: Changing field colors through broker
Hi Igal,
It depends on what exactly you're trying to achieve.
One method is to use a formatter helper function in your data broker, and use the 'htmlText' format on the data field. Such a formatter helper function could look something like:
and then your data field would have an expression similar to:
If the customer's balance is negative, the balance will be printed in red; if the balance is 0 then the balance will pe printed in black with a yellow background. Admittedly a silly example, but quite a nifty way if all you need is to manipulate data field formatting.
The only other option (right now) is to use multiple items on the layout, each with the proper formatting in place, and with mutually exclusive printing conditions. This can be applied to any type of report item (not just data fields) but can be a bit cumbersome to setup.
HTH,
Jan Schenkel.
It depends on what exactly you're trying to achieve.
One method is to use a formatter helper function in your data broker, and use the 'htmlText' format on the data field. Such a formatter helper function could look something like:
Code: Select all
function formattedData pData
local tFormattedData
put "<p>" into tFormattedData
if pData is a number and pData < 0 then
put "<font color=" & quote & "red" & quote & ">" & pData after tFormattedData
else if pData is a number and pData = 0 then
put "<font bgcolor=" & quote & "yellow" & quote & ">" & pData after tFormattedData
else
put htmlSafe(pData) after tFormattedData
end if
put "</p>" after tFormattedData
return tFormattedData
end formattedData
function htmlSafe pData
replace "&" with "&" in pData
replace quote with """ in pData
replace "<" with "<" in pData
replace ">" with ">" in pData
return pData
end htmlSafe
Code: Select all
formattedData(sCustomer["balance"])
The only other option (right now) is to use multiple items on the layout, each with the proper formatting in place, and with mutually exclusive printing conditions. This can be applied to any type of report item (not just data fields) but can be a bit cumbersome to setup.
HTH,
Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com
http://www.quartam.com