Forms 为什么我的Extjs模型/记录只保存它';网络流量和.NET显示完整记录时的Id字段?
我这里有一个相当奇怪的bug/问题,我似乎无法解决 在我的网格的双击事件中,我向我的Api控制器发送了一个请求,请求获得一条“合同”记录,以便加载到ExtJs端的表单中。NET调试会发回包含所有字段的正确“合同”记录 网络流量还显示,已使用所有字段检索记录,如下所示。 但是,当在我的加载的成功回调中记录记录时,我只有ID字段 这意味着在将记录加载到表单中时,不会显示任何字段 模型如下所示Forms 为什么我的Extjs模型/记录只保存它';网络流量和.NET显示完整记录时的Id字段?,forms,extjs,model,record,network-traffic,Forms,Extjs,Model,Record,Network Traffic,我这里有一个相当奇怪的bug/问题,我似乎无法解决 在我的网格的双击事件中,我向我的Api控制器发送了一个请求,请求获得一条“合同”记录,以便加载到ExtJs端的表单中。NET调试会发回包含所有字段的正确“合同”记录 网络流量还显示,已使用所有字段检索记录,如下所示。 但是,当在我的加载的成功回调中记录记录时,我只有ID字段 这意味着在将记录加载到表单中时,不会显示任何字段 模型如下所示 Ext.define('Heating.model.contract.Contract', { e
Ext.define('Heating.model.contract.Contract', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'auto' },
{ name: 'organisationId', type: 'auto' },
{ name: 'organisation', type: 'auto' },
{ name: 'systemTypeId', type: 'auto' },
{ name: 'systemType', type: 'auto' },
{ name: 'description', type: 'auto' },
{ name: 'deleted', type: 'auto' },
{ name: 'startDate', type: 'date' },
{ name: 'endDate', type: 'date' },
{ name: 'lastModified', type: 'date', dateFormat: 'c' }
],
validations: [
{ type: 'presence', field: 'description'},
{ type: 'length', field: 'description', max: 255},
{ type: 'presence', field: 'organisationId'}
],
proxy: {
type: 'rest',
url: Heating.util.Config.BaseUrl + 'api/contract',
noCache: true,
filterParam: 'filter',
reader: {
type: 'json',
root: 'data',
totalProperty: 'total',
messageProperty: 'message'
},
writer: {
type: 'json'
}
}
});
和商店
Ext.define('Heating.store.contract.Contracts', {
extend: 'Ext.data.Store',
model: 'Heating.model.contract.Contract',
storeId: 'contracts',
autoLoad: false,
remoteFilter: true,
listeners: {
load: function(store, records) {
console.log('Contract store loaded');
console.log(store.getCount());
}
}
});
有什么想法吗?提前谢谢 我觉得此图像中的
data
属性有误
您的记录似乎位于另一个数组中的一个数组中。像这样(不正确):
数据根应该是从服务器端返回的记录对象的单个数组,如下所示:(正确)
加热、模型、合同、合同是什么样子的?也可能与Ext.data定义的代理有关。Reader同意@Geronimo,如果您可以使用代理添加extjs中的模型和存储代码,那将很有帮助。感谢各位的评论,这些已经添加到问题中。现场谢谢!我的逻辑是发回一个列表项,其中包含另一个带有单个对象的列表项。
{
success: true,
total: 1,
message: 'blah blah blah',
data:
[
[
{
id: "record-1",
//etc
}, {
id: "record-2",
//etc
}
]
]
}
{
success: true,
total: 1,
message: 'blah blah blah',
data:
[
{
id: "record-1",
//etc
}, {
id: "record-2",
//etc
}
]
}