在Razor视图中打印特定的表/行

时间:2019-03-04 19:21:07

标签: javascript html razor printing

这似乎是一个琐碎的问题,但是我需要打印表中的“ ”块。以下是我的Razor视图,该视图遍历数据,一切看起来不错,但各个部分不可打印。有什么方法可以使各个部分可打印吗?

<table class="table table-condensed table-responsive table-striped">
    @{ var previousheader = ""; }

    @foreach (var item in Model)
    {
        if (item.TrmnlGrp_Description_TEMP != "" && item.TrmnlGrp_Description_TEMP != previousheader)
        {
            previousheader = item.TrmnlGrp_Description_TEMP;

            <tr>
                <td colspan="6" style="padding:5px; background:#808080">
                    <b>@Html.DisplayName(item.TrmnlGrp_Description_TEMP)</b>
                </td>
                <td style="padding:5px; background:#808080">
                    <input type="button" name="print" value="Print" />
                </td>
            </tr>
            <tr>
                <th>
                    Vendor
                </th>
                <th>
                    Terminal
                </th>
                <th>
                    Eff. Date
                </th>
                <th>
                    Diesel
                </th>
                <th>
                    Regular
                </th>
                <th>
                    Mid
                </th>
                <th>
                    Premium
                </th>
            </tr>
        }
        else
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Vend_Description_TEMP)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Trmnl_Description_TEMP)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Fuelcost_EFF_DateTime_TEMP)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Diesel)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Regular_Unleaded)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Midgrade_Gasoline)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Premium_Unleaded_Gas)
                </td>
            </tr>
        }
    }
</table>

0 个答案:

没有答案