我有從控制器綁定數據存儲的問題。ExtJs 4和asp.net mvc 3數據加載問題。
在JS側我有以下代碼:
function buildGrid() {
console.log("0");
var store = new Ext.data.JsonStore(
{
url: '@Url.Content("~/Home/GridData")',
root: 'data',
totalProperty: 'total',
fields: ['Id', 'Name', 'State', 'Age']
});
console.log("1");
store.load({ params: { start: 0, limit: 15} });
console.log("2");
}
控制器代碼loks像:
public JsonResult GridData(int start, int limit)
{
var contact = new List<Contact> {
new Contact(){ Name= "Smith", State = "NU", Age =24},
new Contact(){ Name= "Adam", State= "LU", Age =32},
new Contact(){ Name = "Eve", State= "WA", Age=18},
new Contact(){ Name= "Chun Li", State="LI", Age=34}
};
return Json(new { total = contact.Count, data = contact, }, JsonRequestBehavior.AllowGet);
}
我可以螢火控制檯上看到0和1,但代替2-我得到一個錯誤:
url is undefined
return url + (url.indexOf('?') === -1 ? '?' : '&') + s;
ext-all-debug.js (line 5040)
我不知道我在做什麼錯。
在此先感謝您的任何建議。