Modules
次のような
データベースにこのテーブルがあります
データベースとやり取りするには、エンティティ フレームワークを使用します。これが私が行ったことです。
public class SISContext : SoramaCoreContext
{
public SISContext()
{
if(HttpContext.Current == null)
{
Database.SetInitializer<SISContext>(null);
}
}
public DbSet<Module> Modules { get; set; }
}
jtable の使用に関する知識がほとんどないか、まったくありません。CodeProjectでいくつかのチュートリアルを見ました
私のモジュールモデルは次のJsonResult
ようjtable
になります
public class Module
{
public long Id { get; set; }
public long ModuleTypeId { get; set; }
public ModuleType ModuleType { get; set; }
public string ModuleId { get; set; }
public PropertyConfiguration PropertyConfiguration { get; set; }
public DateTime DateEntered { get; set; }
}
そして、これは私がコントローラーでやろうとしたことです
[HttpPost]
public JsonResult Index()
{
try
{
List<Module> modules = _db.Modules.ToList();//Don't even know if this collects all the data from table....Any suggestion how to do it?
return Json(new { Result = "OK", Records = modules });
}
catch (Exception ex)
{
return Json(new {Result = "ERROR", Message = ex.Message});
}
}
これは私が自分の見解でやろうとしたことです。今は試してみるために jtable を使って表示しModuleId
たいだけです。DateEntered
@{
ViewBag.Title = "Index";
Layout = "~/Views/shared/_BootstrapLayout.basic.cshtml";
}
@section head{
<link href="@Url.Content("~/Content/jtable.2.2.0/themes/metro/blue/jtable.css")" />
<script type="text/javascript" src="~/Scripts/jquery-2.0.2.js"></script>
<script type="text/javascript" src="~/Scripts/jquery-ui-1.10.3.js"></script>
<script type="text/javascript" src="~/Scripts/jtable/jquery.jtable.js"></script>
}
<div id="ModuleTable" style="width: 580px; margin: auto;"></div>
<script type="text/javascript">
$(document).ready(function() {
$('#ModuleTable').jtable({
title: 'Module List',
fields: {
ModuleId: {
key: true,
create: false,
edit: false,
list: false
},
DateEntered: {
title: 'Date Entered',
Width: '15%'
}
}
});
$('#ModuleTable').jtable('load');
});
</script>
私がやっていることは間違っていることはわかっていますが、ここで何か良い助けを得ることができるかもしれません。
現在、エラーが発生します:
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
So, basically I want to show the table in in picture in my view using jtable.