MVC4 と Entity Framework を使用して web アプリを開発しています。私の見解の 1 つでは、すべての詳細を含む人物のリストがあります。最初は姓と名しか表示されていませんが、詳細を表示するためのリンクが用意されているので、可能な限り動的にしたいと考えています。
私のアクションはJson(object, JsonRequestBehavior.AllowGet)
アイデアはありますか?
編集:私の行動
public ActionResult ListByOwner(long id)
{
var productallocations = db.ProductAllocations.Where(obj => obj.Id_Person == id).Include("Product");
return PartialView(productallocations);
}
私の見解 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<meta name="viewport" content="width=device-width" />
@Styles.Render("~/Content/css")
@Styles.Render("~/Content/bootstrap")
@Scripts.Render("~/bundles/modernizr")
<script src="../../Scripts/globalize.js" type="text/javascript"></script>
<script src="../../Scripts/globalize.culture.fr-FR.js" type="text/javascript"></script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="@Url.Action("Index", "Home")">BuSI Material Manager</a>
<div class="nav-collapse collapse">
<p class="navbar-text pull-right">
Logged in as @User.Identity.Name
</p>
<ul class="nav">
<li>@Html.ActionLink("Home","Index","Home")</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Persons <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("All persons list","Index","Person")</li>
<li>@Html.ActionLink("All allocations list", "Index", "ProductAllocation")</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Cards<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("All phone cards list", "Index", "PhoneCard")</li>
<li>@Html.ActionLink("All fuel cards list", "Index", "VehicleFuelCard")</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("All products list", "Index", "Product")</li>
<li>@Html.ActionLink("Products in stock", "ProductStock", "Product")</li>
<li>@Html.ActionLink("Allocated products", "AllocatedProducts", "Product")</li>
<li class="divider"></li>
<li>@Html.ActionLink("Product types", "Index", "ProductType")</li>
<li>@Html.ActionLink("Product companies", "Index", "ProductCompany")</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Vehicles <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>@Html.ActionLink("All vehicles list", "Index", "Vehicle")</li>
<li>@Html.ActionLink("Available vehicles", "AvailableVehicles", "Vehicle")</li>
<li>@Html.ActionLink("Allocated vehicles", "AllocatedVehicles", "Vehicle")</li>
<li class="divider"></li>
<li>@Html.ActionLink("Vehicle types", "Index", "VehicleType")</li>
<li>@Html.ActionLink("Vehicle motor types", "Index", "VehicleMotorType")</li>
<li class="divider"></li>
<li><a href="@Url.Action("Index", "VehicleInsuranceContract")">Insurance contracts</a></li>
<li><a href="@Url.Action("Index", "VehicleLeasingContract")">Leasing contracts</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id="body">
@RenderSection("featured", required: false)
@RenderBody()
</div>
<footer>
<p>Developed by me.</p>
</footer>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
<script src="../../Scripts/Utils.js" type ="text/javascript"></script>
</body>
</html>
バンドル :
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}