0

同じタブ(タブをクリックするたびに同じビュー)の異なる結果を同じビューで表示しようとしています。同じビューで複数回フィルタリングされたMVCテーブル

確認してください明確にする:

ビューコード:

@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> 

    } 

をこれが解決された後、私は少ない列を持つすべての "タブ" を通じて、テーブルを複製します。私はコントローラに検索機能を追加しましたが、これはよりよい方法です。これは入力後に必要なものだけを返すためです。

は、ここでコントローラのコードです:

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()); 
     } 

私はフィルタリングが答えであると信じていますが、私は現時点でこだわっています。

答えて

0

私が言ったように、フィルタリングは答えでした。 問題の答えにちょうど従った:MVC 3 model foreach filter

関連する問題