HOW TO change the field's data on fly

Talk and info about common issues

Moderator: alexandrleonenko

Site Admin
Site Admin
Posts: 6098
Joined: Jan 7th, '09, 23:18

HOW TO change the field's data on fly

Postby administrator » Apr 20th, '09, 22:08

Changing the field's data on fly:

1. Define in required field following attribute:

Code: Select all

"on_item_created"=>"setColor" for appropriate field.

2. Write function:

Code: Select all

function setColor($field_value){
     if(strlen($field_value) > 5){
         return "<span style='color:red'>".$field_value."</span>";
         return "<span style='color:blue'>".$field_value."</span>";       

3. Using SQL:

Code: Select all

    WHEN field_x = 1 THEN '<div style=\"display:block;background-color:green;\">Yes</div>'
    WHEN field_x = 0 THEN '<div style=\"display:block;background-color:red;\">No</div>'
    ELSE ''
END as my_field

Return to “ApPHP DataGrid {HOW TO}”