クリックするとパーシャルビューが読み込まれるテーブルがあります。私は、コントローラの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>
モデルを部分ビューに渡さないようにして、コードが 'NullReferenceException'をスローするようにします。' null'の 'Items'プロパティにアクセスできます(' 500(Internal Server Error)ブラウザで) –
ああ!私は今あなたを理解することができます! Createのビューを返す 'JsonResult Create'にLINQがあります。しかし、私は 'ActionResult RetrieveItemPrice'に1つも持っていません。私は正しい? Btw、私は '500(内部サーバーエラー)'を取得していません –
しかし、私は少なくとも私のヘッダーテーブルを表示する必要がありますと思う。私は最初に実験しようとしています –