我试图在同一视图中每次单击选项卡时显示同一个表的不同结果(组列值)。
澄清请检查:
观看代码:
@model IEnumerable<RapidScan_v2.Models.lu_performance_reason>
@{
ViewBag.Title = "Index";
}
<h2>Playbook</h2>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"> <a href="#Consumables" aria-controls="Consumables" role="tab" data-toggle="tab">Consumables</a></li>
<li role="presentation"> <a href="#DocuCareLabour" aria-controls="DocuCareLabour" role="tab" data-toggle="tab">DocuCare Labour</a></li>
<li role="presentation"> <a href="#Parts" aria-controls="Parts" role="tab" data-toggle="tab">Parts</a></li>
<li role="presentation"> <a href="#PrintProductionLabour" aria-controls="PrintProductionLabour" role="tab" data-toggle="tab">Print Production Labour</a></li>
<li role="presentation"> <a href="#Revenue" aria-controls="Revenue" role="tab" data-toggle="tab">Revenue</a></li>
<li role="presentation"> <a href="#TechnicalService" aria-controls="TechnicalService" role="tab" data-toggle="tab">Technical Service</a></li>
<li role="presentation"> <a href="#Depreciation" aria-controls="Depreciation" role="tab" data-toggle="tab">Depreciation</a></li>
<li role="presentation"> <a href="#OtherCosts" aria-controls="OtherCosts" role="tab" data-toggle="tab">Other Costs</a></li>
</ul>
@section LeftMenu{
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="Consumables">
@using (Html.BeginForm())
{
<p>
Consumables: @Html.Hidden("search1","Consumables")
<input type="submit" value="Search" />
</p>
}
<table class="table">
<tr>
<th>
Perf Reason
</th>
<th>
Action
</th>
<th>
Action Description
</th>
<th>
Info EU
</th>
<th>
Info US
</th>
<th>
Helper Team
</th>
<th>
Target
</th>
<th>
Group
</th>
<th>
Cost Reason
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.dsc_performance_reason)
</td>
<td>
@Html.DisplayFor(modelItem => item.dsc_investigation_actions)
</td>
<td>
@Html.DisplayFor(modelItem => item.dsc_actions)
</td>
<td>
@Html.DisplayFor(modelItem => item.dsc_additional_info_europe)
</td>
<td>
@Html.DisplayFor(modelItem => item.dsc_additional_info_usa)
</td>
<td>
@Html.DisplayFor(modelItem => item.lu_action_helper.dsc_action_helper)
</td>
<td>
@Html.DisplayFor(modelItem => item.lu_action_target.dsc_action_target)
</td>
<td>
@Html.DisplayFor(modelItem => item.lu_cost_bucket.dsc_cost_bucket)
</td>
<td>
@Html.DisplayFor(modelItem => item.lu_cost_reason.dsc_cost_reason)
</td>
<td>
@Html.ActionLink("Add to Contract", "Create", "fact_contract_actions_mn", new { id = item.cod_performance_reason }, null)
</td>
</tr>
}
</table>
</div>
<div role="tabpanel" class="tab-pane" id="DocuCareLabour">
<p>DocuCare Labour</p>
</div>
<div role="tabpanel" class="tab-pane" id="Parts">
<p>Parts</p>
</div>
<div role="tabpanel" class="tab-pane" id="PrintProductionLabour">
<p>Print Production Labour</p>
</div>
<div role="tabpanel" class="tab-pane" id="Revenue">
<p>Revenue</p>
</div>
<div role="tabpanel" class="tab-pane" id="TechnicalService">
<p>Technical Service</p>
</div>
<div role="tabpanel" class="tab-pane" id="Depreciation">
<p>Depreciation</p>
</div>
<div role="tabpanel" class="tab-pane" id="OtherCosts">
<p>Other Costs</p>
</div>
</div>
}
我将通过所有&#34;标签&#34;复制表格。解决此问题后,列数更少。我在控制器上添加了一个搜索功能,但我相信这是一个更好的方法,因为这只会在输入后返回我想要的内容。
这是控制器代码:
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using RapidScan_v2.Models;
namespace RapidScan_v2.Controllers
{
public class lu_performance_reasonController : Controller
{
private RapidScanEntities2 db = new RapidScanEntities2();
// GET: lu_performance_reason
public ActionResult Index(string search1)
{
var lu_performance_reason = from lpr in db.lu_performance_reason.Include(l => l.lu_action_helper).Include(l => l.lu_action_target).Include(l => l.lu_cost_bucket).Include(l => l.lu_cost_reason)
select lpr;
if (!string.IsNullOrEmpty(search1))
{
lu_performance_reason = lu_performance_reason.Where(lpr => lpr.lu_cost_bucket.dsc_cost_bucket.Contains(search1));
}
return View(lu_performance_reason.ToList());
}
我相信过滤就是答案,但我现在陷入困境。