Back

Table Cell formating
colorLens
Dynamicly change color of column or cell, and column attributes too. You can use this property to enter a color such as 'white' or 'black', or use the numeric RGB values where #000000 and #FFFFFF is white. To set dynamic colors in your columns, set the first character to an equals (=), then you can use the PHP's ternary logical operator or your own pre-defined function to perform checks and comparisons. PHP has a nice way of allowing you to choose between multiple values in one line of code: `= (expr) ? "value if expr is true" : "value if expr is false"` An example is given a column named UnitsInStock, and we want to color the column red if the units are less than 10: `=({UnitsInStock} < 10)? "red" : ""` You can also use any global variables defined in the $GLOBALS array using {$VARNAME}, for example {$PHP_SELF}. The colorLens property can access any column in the current row using the {columnname} syntax just like the powerLens. Additional Macro Variables Available {NBSP} = ' ' {SEMICOLON} = ';' {_HILITE_RECNO_} = current record number {_LENSID_} = the phpLens object's id {_ODDC_} = the odd row color {_EVENC_} = the even row color {_SELECTC_} = the hilite color for the current line {_HASDETAILS_} = whether the detail grid is visible Changing Column Attributes You can also change column widths with this property by taking advantage of a side-effect. Any attribute can be added to the TD tag using colorLens. See example in syntax. Note that setting the column width is discretionary. The browser can override this setting if it wants to. However since phpLens 2.6, we have the tdLens property, which allows you direct access to all td attributes. Note however that tdLens does not do column interpolation (eg {col1}) nor php code processing (with =). Syntax `$lens->colorLens = 'totals^yellow'; // color the totals column yellow $lens->colorLens = 'totals^yellow width=200px'; // ... sets the width too $lens->colorLens = 'totals^yellow;name^#0000FF'; // and name is blue` Basic:Yes Advanced/Enterprise:Yes DynamicEdit:Yes [Version 1.0]