Changing field colors through broker

Whether you're using the Standard or Professional Edition of Quartam Reports, this is the place to ask general questions about using this industry-level reporting tool for LiveCode.

Changing field colors through broker

Postby igalperry » Sun Jun 26, 2011 3:06 pm

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
igalperry
 
Posts: 9
Joined: Sat Jan 22, 2011 4:37 am

Re: Changing field colors through broker

Postby JanSchenkel » Sun Jun 26, 2011 5:40 pm

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:
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 "&amp;" in pData
   replace quote with "&quot;" in pData
   replace "<" with "&lt;" in pData
   replace ">" with "&gt;" in pData
   return pData
end htmlSafe

and then your data field would have an expression similar to:
Code: Select all
formattedData(sCustomer["balance"])

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.
Quartam Developer Tools for LiveCode
http://www.quartam.com
JanSchenkel
Site Admin
 
Posts: 110
Joined: Sun Jul 18, 2010 5:21 pm
Location: Aalst, Belgium


Return to Using Quartam Reports - All Editions

Who is online

Users browsing this forum: No registered users and 1 guest

cron