我正在開發使用EF的ASP.Net mvc 4應用程序。 這是客戶端/ index.cshtml(添加的ExtJS之前)ASP.NET MVC 4和Ext JS 4 Grid Panel
@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: '/例子/ GetUsers',」 !!我應該替換它在我的情況!
工作正常,但無法加載數據。我有空的網格! – ImnotaGeek 2013-04-04 19:02:31