我有一个模特
Ext.define('MyCompany.model.Customer', {
extend: 'Ext.data.Model',
fields: [
'id', 'name', 'taxID', 'tradeID', 'vatID', 'email'
]
}
和商店
Ext.define('MyCompany.store.Customers', {
extend: 'MyCompany.lib.base.Store',
model: 'MyCompany.model.Customer',
api: {
read: $["crmModule.CustomerController"].list,
create: $["crmModule.CustomerController"].save
}
});
问题是,在调用store.load()
时(例如从控制台调用),字段vatID
未同步。我可以在store.data.items[0].raw
中看到该字段,但在store.data.items[0].data
中该字段为空。我该如何调试此问题? ExtJS在哪里进行从原始数据到实际记录的转换?
答案 0 :(得分:0)
查找为extractData
定义的名为Ext.data.reader.Reader
的方法。有以下几行:
// If the server did not include an id in the response data, the Model constructor will mark the record as phantom.
// We need to set phantom to false here because records created from a server response using a reader by definition are not phantom records.
record.phantom = false;
// Use generated function to extract all fields at once
me.convertRecordData(convertedValues, node, record);
records.push(record);
当您进入方法convertRecordData
时,您将看到生成的临时代码以进行实际转换,如下所示:
return function(dest, source, record) {
value = source["id"];
if (value !== undefined) {
dest["id"] = value;
}
value = source["name"];
if (value === undefined) {
if (me.applyDefaults) {
...