我的问题与这个问题非常相似:
但是在语法和行为上有点不同,我花了几天时间通过多种方式尝试解决但失败了。
请注意:我必须通过调用父构造函数而不是 json 字段构造来保持 SharpKit.NET 生成行为,如下面的代码
Ext.define("Core.Scripts.model.Book", {
extend: "Ext.data.Model",
fields: ["title", "pages"] // Do not use this
});
Ext.define("Core.Scripts.model.Book", {
extend: "Ext.data.Model",
constructor: function () {
this.callParent([{ fields: ["title", "pages"] }]); // Use this
}
});
这是我在 jsfiddle http://jsfiddle.net/thanhptr/LqXan/上的简化版本的链接。Bellow是我复制的代码,此代码仍然无法修复:
Ext.define("Core.Scripts.model.Book", {
extend: "Ext.data.Model",
constructor: function () {
this.callParent([{ fields: ["title", "pages"] }]);
}
});
Ext.define("Core.Scripts.store.Store", {
extend: "Ext.data.Store",
constructor: function () {
this.callParent([{
model: "Core.Scripts.model.Book",
data: [
{ title: "book 1", pages: 10 },
{ title: "book 2", pages: 20 }
]
}]);
}
});
Ext.define("Core.Scripts.view.GridPanel", {
extend: "Ext.grid.Panel",
constructor: function () {
this.callParent([{
store: new Core.Scripts.store.Store(),
region: "center",
columns: [
{ header: "title", dataIndex: "title" },
{ header: "pages", dataIndex: "pages" }
]
}]);
}
});
Ext.define("Core.Scripts.view.DetailViewport", {
extend: "Ext.container.Viewport",
constructor: function () {
this.callParent([{
frame: true,
layout: "border",
items: [new Core.Scripts.view.GridPanel()]
}]);
}
});
Ext.onReady(function () {
var viewPort = new Core.Scripts.view.DetailViewport();
});