gpt4 book ai didi

javascript - 如果表格空白并显示文本,则隐藏按钮

转载 作者:行者123 更新时间:2023-11-30 10:18:22 25 4
gpt4 key购买 nike

如果我的表中没有返回结果,我会尝试隐藏一个按钮并显示文本。

如果我的表有什么,下面的代码:

<table class="stripped" id="table">
<tr>
<th>DB ID</th>
<th>
@Html.ActionLink("Environment", "Index", new { sortOrder = ViewBag.EnviroSortParam })
</th>
<th>
@Html.ActionLink("Product", "Index", new { sortOrder = ViewBag.ProductSortParam })
</th>
<th>
@Html.ActionLink("Test Type", "Index", new { sortOrder = ViewBag.TestTypeSortParam })
</th>
<th>
@Html.ActionLink("Scenario", "Index", new { sortOrder = ViewBag.ScenarioSortParam })
</th>
<th>
@Html.ActionLink("Times Run", "Index", new { sortOrder = ViewBag.TimesRunSortParam })
</th>
<th>
@Html.ActionLink("Failed Count", "Index", new { sortOrder = ViewBag.FailedCountSortParam })
</th>
<th>
@Html.ActionLink("Last 'Passed' Date", "Index", new { sortOrder = ViewBag.LastPassedDateParam })
</th>
<th>
@Html.ActionLink("Last 'Failed' Date", "Index", new { sortOrder = ViewBag.LastFailedDateParam })
</th>
<th>
Actions
</th>
</tr>

@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Environment)
</td>
<td>
@Html.DisplayFor(modelItem => item.Product)
</td>
<td>
@Html.DisplayFor(modelItem => item.TestType)
</td>
<td>
@Html.DisplayFor(modelItem => item.Scenario)
</td>
<td>
@Html.DisplayFor(modelItem => item.TimesRun)
</td>
<td>
@Html.DisplayFor(modelItem => item.FailedCount)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastPassedDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.LastFailedDate)
</td>
<td class="Link">
@if (item.LastFailedDate != null)
{
if (Convert.ToDateTime(item.LastFailedDate).Date == DateTime.Now.Date)
{
@Html.ActionLink("Show Details", "Details", new { id = item.Id })
<i class="fa fa-chevron-right"></i>
}
}
</td>
</tr>
}

下面的代码显示了我的导出按钮的代码:

<div class="RightAlign">
<button class="butstyle" id="Export" onclick="Export_Click" title="Click to export the results above as a CSV file.">
Export To Excel <i class="fa fa-table"></i>
</button>
</div>

正如我所说,如果没有找到结果并显示以下内容,我希望隐藏按钮:

<p id="NRF" class="NRF">No Test Runs Found.</p>

我该怎么做,或者最好的方法是什么,因为我似乎无法理解它。我正在使用 HTML5 和 MVC5。

最佳答案

@if(Model.Count>0)
{

<div class="RightAlign">
<button class="butstyle" id="Export" onclick="Export_Click" title="Click to export the results above as a CSV file.">
Export To Excel <i class="fa fa-table"></i>
</button>
</div>
}

else
{
<p id="NRF" class="NRF">No Test Runs Found.</p>
}

关于javascript - 如果表格空白并显示文本,则隐藏按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22632855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com