我正在使用 EF 开发 ASP.Net mvc 4 应用程序。这是 Client/index.cshtml(在添加 ExtJS 之前)
@model IEnumerable<Proj.Client>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name_Clt)
</th>
<th>
@Html.DisplayNameFor(model => model.LName_Clt)
</th>
<th>
@Html.DisplayNameFor(model => model.Birthday_Clt)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name_Clt)
</td>
<td>
@Html.DisplayFor(modelItem => item.LName_Clt)
</td>
<td>
@Html.DisplayFor(modelItem => item.Birthday_Clt)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID_Client }) |
@Html.ActionLink("Details", "Details", new { id=item.ID_Client }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID_Client })
</td>
</tr>
}
</table>
我正在关注这篇博文,但我无法在上面加载数据。 http://cincolabs.com/2012/04/10/asp-net-mvc-4-ext-js-4-gridpanel/
我创建了另一个 ClientController 。
public JsonResult GetUsers()
{
var entities = new Entities();
//What is important is to return the data as JSON.
return Json(entities.Clients.ToList(), JsonRequestBehavior.AllowGet);
}
我应该替换此代码吗?
public ActionResult Index()
{
var db = new Entities();
return View(db.Clients.ToList());
}
另一个问题 :
// Set up a model to use in our Store
Ext.define('Client', {
extend: 'Ext.data.Model',
fields: [
{ name: 'First_Name', type: 'string' },
{ name: 'Last_Name', type: 'string' },
{ name: 'Email', type: 'string' },
{ name: 'Date_Created', type: 'date', dateFormat: 'MS'}
]
});
var userStore = Ext.create('Ext.data.Store', {
model: 'Client',
proxy: {
type: 'ajax',
url: '/Examples/GetUsers',
reader: {
type: 'json',
root: 'users'
}
},
autoLoad: true
});
这是什么意思“url:'/Examples/GetUsers',”!我应该在我的情况下更换它吗?