set_conditional_value() *

* Please note this feature is not available in Lite and Basic versions.

  • Parameters:
    • $col_name: Name of the column. Its value is used as the left operand for comparison.
    • $condition: comparison condition that compares given left and rigth hand operand with comparison operator . e.g. ” > 10 “; ” = ‘abc'”; ” != true ” etc.
    • $formatoptions:  an array stores CSS style format options. The value can be text, HTML, or even CSS class. See example.
      • TCellValue: value to display when condition is True
      • FCellValue: value to display when condition is False
  • Description:
    • It formats and displays value in a cell when specified condition is met. You can think it as a simplified version to set_conditional_format() method.
  • Remark:
    • The condition is not “stackable” for a single column. In other words, only one condition can be applied to any giving column.
  • Example:

Note that tstyle and fstyle are CSS styles used as the formatoptions.

1
2
3
4
5
6
7
8
.tstyle
{
display:block;background-image:none;margin-right:-2px;margin-left:-2px;height:14px;padding:5px;background-color:green;color:navy;font-weight:bold
}
.fstyle
{
display:block;background-image:none;margin-right:-2px;margin-left:-2px;height:14px;padding:5px;background-color:yellow;color:navy
}

PHP Code

1
2
3
4
5
6
7
$dg->set_conditional_value("isClosed", "==1", array(
"TCellValue"=>"<img src="SampleImages/checked.gif" alt="" />",
"FCellValue"=>"<img src="SampleImages/unchecked.gif" alt="" />"));

$dg->set_conditional_value("status", "=='Complete'", array(
"TCellStyle"=>"tstyle",
"FCellStyle"=>"fstyle"));

No related content found.

Tags: