Get KoolPHP UI with 30% OFF!

How can I replace database values with images (or other HTML code)?

Bodo
I have to switch cell values to a picture depending on the value I got from database. I tried to do it via "ValueMap", but I only get replaced text iin the cells, the HTML doesn't seem to be interpreted. Is there another way to do it?
My (shortened) Code:
class PhoneMap implements GridIValueMap
  { function mapValue($value, $column)
      { if ($column == "type")
          { switch($value)
              { case 1:
                  $value = "<img src=\"picts/Callin.png\" />";
                  break;
                  
                default:
                  break;
              }
          }
        return $value;
    }
    
   function inverseMapValue($value, $column)
     { return $value;
     }
  }

Thanks for Your help!
Posted Nov 8, 2015 Kool
David
Hi Bodo,
Supposed the column using field "type" of yours is a GridBoundColumn, you could set the following property to make the column's cells display html code:
$column->AllowHtmlRender = true;

Hope this help!
Rgds,
Posted Nov 9, 2015 , edited Nov 9, 2015 Kool
Anthony Amolochitis
You can also make use of the grid event handler with custom columns and grid row pre-render event.
Posted Nov 9, 2015 Kool
Bodo
Thanks, it was an auto generated table and I sadly didn't find out how to use this switch on this type (except changing the default behaviour in the grid.js file).
After building the table manually and using this switch the problem is solved.
Posted Nov 13, 2015 Kool