i want to change Status column - with color in CMS october in columns.yaml ...
how i add this :
<div class="control-list">
<table class="table data">
<thead>
<tr>
<th style="width: 150px"><span>Status</span></th>
<th class="active sort-asc"><a href="/">Title</a></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<span class="oc-icon-circle text-success">
Approved
</span>
</td>
<td>The sun is shining</td>
</tr>
<tr>
<td>
<span class="oc-icon-circle text-danger">
Cancelled
</span>
</td>
<td>The weather is sweet here</td>
</tr>
</tbody>
</table>
</div>
How can I add such a thing into my system model?
Entire row (easier)
You can apply a class to the entire row overwriting
listInjectRowClass
in your controller and return the name of one of the classes listed in the docs, for example:This will result in something like this:
Just one column of the row
This is a little more tricky, basically you have to use a partial for rendering the column.
In your
columns.yaml
And in the partial file
_content_column.htm
you need to have something like this:where, as the docs say:
$value
is the default cell value$record
is the model used for the cellSo, for this example, the model need a function called
getColumnStatusClassAttribute
which will return the proper class name.