Hello,
I would like to change the style of some nodes based on a condition. For example how would I change the background color of any node that has a value in a t2.date column?
It follows my TreeView widget code which is inside a view.
<?= TreeView::widget([ 'query' => MyDbTable::find() ->join("left join", "t2", "t1.id=t2.id_t1") ->select(['*', t2.date, 't1.id as id', CONCAT_WS(" ", code, name) as name']) ->where(['t1.id_person' => $id_p]) ->addOrderBy('root, lft'), 'headingOptions' => ['label' => 'Page 1'], 'rootOptions' => ['label' => '<span class="text-primary">'.$model->getFullname().'</span>'], 'topRootAsHeading' => false, // this will override the headingOptions 'fontAwesome' => true, 'isAdmin' => false, 'iconEditSettings' => [ 'show' => 'list', 'listData' => [ 'folder' => 'Sector', 'cogs' => 'Machine', 'cubes' => 'Operator', ] ], 'displayValue' => $idp, 'nodeAddlViews' => [ Module::VIEW_PART_1=> '@backend/views/page1/treemanager', Module::VIEW_PART_6=> '@backend/views/page1/dettaglio', ], 'emptyNodeMsg' => 'Neo node available', 'showIDAttribute' => false, 'softDelete' => false, 'cacheSettings' => ['enableCache' => true], 'allowNewRoots'=>false, 'toolbar'=>[ TreeView::BTN_CREATE => [ 'alwaysDisabled' => true, ], TreeView::BTN_CREATE_ROOT => [ 'alwaysDisabled' => true, ], TreeView::BTN_REMOVE => [ 'alwaysDisabled' => true, ], TreeView::BTN_SEPARATOR, TreeView::BTN_MOVE_UP => [ 'alwaysDisabled' => true, ], TreeView::BTN_MOVE_DOWN => [ 'alwaysDisabled' => true, ], TreeView::BTN_MOVE_LEFT => [ 'alwaysDisabled' => true, ], TreeView::BTN_MOVE_RIGHT => [ 'alwaysDisabled' => true, ], TreeView::BTN_SEPARATOR, TreeView::BTN_REFRESH => [ 'alwaysDisabled' => false, ], ] ]); ?>
Thank you in advance!
Best regards,
Custom Style on TreeView node
Kartik V Changed status to publish June 27, 2024