Closed tonyp90 closed 1 year ago
You can try this, use (...)
lets you access variables from the parent scope. But remember, issues are for bugs in Datagrid, not for teaching PHP syntax.
$grid->setRowCallback(function($item, $tr) use ($grid) {
if (!$grid->filterActive && $item->op_exp_date->format('W') % 2) {
$tr->addClass('datagrid-even');
}
});
It was not about syntax. "filterActive" property no not exists, it was just my example. It was about finding the correct property. Just found an array with active filter columns.
if (empty($grid->filter)) {
}
and It's fine now.
There is DataGrid::isFilterActive()
method (https://github.com/contributte/datagrid/blob/master/src/DataGrid.php#L1246). I thought that it would be exposed as DataGrid::filterActive
virtual property by SmartObject
, but I forgot that you'd need a @property-read
annotation for that, which is not present.
Hello, I'm using setRowCallback to distinguish odd and even weeks from date column.
Any tips how to make this active only when user not using any filter/sort?