Created
October 5, 2019 16:15
-
-
Save Jmos/5f44cadb9c91e9d715d9ef74d2cfeca5 to your computer and use it in GitHub Desktop.
Atk table color by dependent value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require '../vendor/autoload.php'; | |
use atk4\ui\App; | |
$app = new App(); | |
$app->initLayout('Centered'); | |
$test_data = [ | |
['name'=>'record1','value'=>'100','datum_field'=>new DateTime('2019-09-29')], | |
['name'=>'record2','value'=>'200','datum_field'=>new DateTime('2019-09-28')], | |
['name'=>'record3','value'=>'300','datum_field'=>new DateTime('2019-09-30')], | |
['name'=>'record4','value'=>'400','datum_field'=>new DateTime('2019-10-01')], | |
]; | |
$table = $app->add('Table'); | |
$table->setSource($test_data); | |
$table->addHook('beforeRow',function($table){ | |
if ($table->current_row['value']==100){ | |
$table->t_row->template[0] = "\n <tr class=\"red\" data-id=\""; | |
}elseif ($table->current_row['value']==200){ | |
$table->t_row->template[0] = "\n <tr class=\"green\" data-id=\""; | |
}else{ | |
$table->t_row->template[0] = "\n <tr data-id=\""; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment