2016-09-28 7 views
0

クリックするとパーシャルビューが読み込まれるテーブルがあります。私は、コントローラのActionResult RetrieveItemPrice()にブレークポイントを置くと、正常にreturn文に行きますが、私のViewにPartialViewを表示していません。テーブルがクリックされたときにJavascriptによって部分ビューがロードされない

コントローラ(ItemController)

public ActionResult RetrieveItemPrice() 
{ 
    return PartialView("~/Views/Item/_ViewItemPrice"); 
} 

ビュー(作成)

... 
<div class="col-sm-8" style="border: 0px solid green; padding:10px;"> 
    <div id="pvItemPrice" class="" style="border: 0px solid green; "> 
    </div> 
</div> 
... 
<script type="text/javascript"> 
    $(document).ready(function() { 
     $("#dbTable").click(function (e) { 
      debugger; 
      $("#pvItemPrice").load('/Item/RetrieveItemPrice'); 
     }); 
    }); 
</script> 

PartialView(_ViewItemPrice)モデルはビューに渡される

@model CDS.Models.ItemViewModel 
@using PagedList.Mvc; 

<div> 
    <table id="dbTable2" class="table table-hover" aria-busy="false"> 
     <thead> 
      <tr class="inner-table-head"> 
       <th class="hidden"> 
        @Html.DisplayNameFor(model => model.itemId) 
       </th> 
       <th> 
        @Html.ActionLink("Item", "Create", new { currentFilter = ViewBag.CurrentFilter }) 
       </th> 
       <th> 
        @Html.ActionLink("Price", "Create", new { currentFilter = ViewBag.CurrentFilter }) 
       </th> 
      </tr> 
     </thead> 
     <tbody id="dbBody2"> 
      @foreach (var item in Model.Items) 
      { 
       <tr> 
        <td class="hidden"> 
         @Html.DisplayFor(modelItem => item.itemid) 
        </td> 
        <td> 
         @Html.DisplayFor(modelItem => item.itemdesc) 
        </td> 
        <td> 
         @Html.DisplayFor(modelItem => item.itemprice) 
        </td> 
       </tr> 
      } 
     </tbody> 
    </table> 
</div> 
+0

モデルを部分ビューに渡さないようにして、コードが 'NullReferenceException'をスローするようにします。' null'の 'Items'プロパティにアクセスできます(' 500(Internal Server Error)ブラウザで) –

+0

ああ!私は今あなたを理解することができます! Createのビューを返す 'JsonResult Create'にLINQがあります。しかし、私は 'ActionResult RetrieveItemPrice'に1つも持っていません。私は正しい? Btw、私は '500(内部サーバーエラー)'を取得していません –

+0

しかし、私は少なくとも私のヘッダーテーブルを表示する必要がありますと思う。私は最初に実験しようとしています –

答えて

0

(CDS.Models .ItemViewModel)?

return PartialView("~/Views/Item/_ViewItemPrice"); 

また、ネットワークツールは応答として何を示していますか? 200または500応答コード?

+1

答えで質問していますか?私は部分的なビューでモデルを渡す方法をOPに示すべきだと思います* –

+0

私は 'ActionResult RetrieveItemPrice()'にLINQがないことがわかりました。ありがとう! @Divはそうだけど。また、少なくともテーブルヘッダーを表示する必要があります。私はそれのためのモデルを使用していません。私はあなたに戻ってきます –

+0

問題を特定するためにPartialViewを単純化しようとしましたが、現在は

Hello
コードしかありません。しかし、 'Create'でテーブルをクリックしてもまだ表示されません。 –

関連する問題