【发布时间】:2020-03-22 13:12:40
【问题描述】:
我在 razor 视图中有一个表格,它显示这样的数据
有些字段我想这样分组
我认为我不会通过分组来实现这一点,因为我会丢失数据。不确定采取什么方法?
这是我的标记
<div class="row">
<table class="arrowes-table table-striped">
<thead>
<tr>
<th>Driver Name</th>
<th>Alarm Type : Count</th>
<th>Total Distance For Period</th>
<th>Avg Per Km Driven</th>
<th>Relative Driver Score</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.DriverBehaviour.OrderByDescending(x => x.DriverName))
{
<tr>
<td>@Html.HiddenFor(m => item.DriverId) @Html.ActionLink(item.DriverName, "Operator", "Operators", new { area = "VehicleManagement", operatorId = item.DriverId })</td>
<td>@item.AlarmType : <span class="brand-red">@item.TypeCount</span></td>
<td>@item.TotalDistanceForPeriod</td>
<td>
@{
var avg = @Math.Truncate(1000 * item.AverageAlarmPerKmDriven) / 1000;
}
@avg
</td>
<td>
@{
var relScore = @Math.Truncate(1000 * @item.RelativeDriverScore) / 1000;
if (relScore.ToString().StartsWith("-") == true)
{
<span class="brand-red">@relScore</span>
}
if (relScore.ToString().StartsWith("-") == false)
{
<span class="brand-green">+@relScore</span>
}
}
</td>
</tr>
}
</tbody>
</table>
</div>
感谢您的任何想法:)
【问题讨论】:
标签: c# html asp.net-mvc razor .net-core