I am using mvc and using the server as a datasource. I am trying to change the color of the column based on the value . I tried to many finding on the net but none is working see at least two of them in the code below.
//This example doesn't do anything.
columns.Bound(p => p.balance).Width(120).Sortable(false).Template(@<text>
@if (item.balance< 0)
{
<div style="background-color: Red;">
@item.balance;
</div>
}
else
{
<div style="background-color: Green;">
@item.amount_residence
</div>
}
</text>);
//This below example throw an error
@(Html.Kendo().Grid(Model).Name("grid").CellAction(cell =>
{
if (cell.Column.Title.Equals("balance"))
{
if (cell.DataItem.balance != null && cell.DataItem.balance.Value < 0)
{
cell.HtmlAttributes["style"] = "background-color: red";
}
}
})
.Columns...