1
Situation I have a table made in html called Payments and in it I have a column called values, I want to leave the fields with values in bold.
Problem: There are collaborators who had value to be paid and others who did not. As I leave only fields with values greater than 0 in bold?
Ideal Scenario: Leave only fields with values greater than 0 in bold.
HTML:
<table id="data-table-default" class="table table-striped table-bordered">
<thead>
<tr>
<th class="col-xs-1 text-center">
@Html.DisplayNameFor(model => model.Salario1)
</th>
<th class="col-xs-1 text-center">
@Html.DisplayNameFor(model => model.Salario2)
</th>
<th class="col-xs-1 text-center">
@Html.DisplayNameFor(model => model.Salario3)
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td class="text-center">
@Html.DisplayFor(a => item.Salario1)
</td>
<td class="text-center">
@Html.DisplayFor(a => item.Salario2)
</td>
<td class="text-center">
@Html.DisplayFor(a => item.Salario3)
</td>
</tr>
}
</tbody>
</table>
You used
<b>
and it didn’t work?– Maniero
Yes but if I put b or Strong in any line it paints bold the idea is only when you have a check greater than 0 then it leaves in bold otherwise it does not leave in bold. I don’t know how to put this part into practice!
– Thiago Correa
And you don’t know how to use one
if
?– Maniero
@Maniero Opa for example would be something like that. if(Meumodel > 0) { <b>Contents</b> }Else{contents} Would that be correct? However I would have to do line by line, I would do in a check only?
– Thiago Correa
That would be about it, now you’re asking something else. There’s even a way to do it in a loop, but you’d have to use a trick since you don’t have one array, then you’d have to create one with the names of the fields. It would also work with a function that abstracts this, would have to call 3 times, but would not have all repetition of code and would not need to create a array. You can even create a new tag to do this in an abstract way. But here we are already talking about another problem other than the question.
– Maniero
@Maniero guy helped a lot, thank you very much even managed to do here. Thanks for the info my friend.
– Thiago Correa