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.
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
igalperry
Posts:9
Joined:Sat Jan 22, 2011 4:37 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Changing field colors through broker

Post by 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

JanSchenkel
Site Admin
Posts:110
Joined:Sun Jul 18, 2010 5:21 pm
Location:Aalst, Belgium
Contact:

Re: Changing field colors through broker

Post by 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 "&" in pData
   replace quote with """ in pData
   replace "<" with "<" in pData
   replace ">" with ">" 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

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable