当我尝试将远程数据加载到网格时,子字段出现此错误:
Cannot read property 'id' of null
我的数据模型:
Ext.define('ruleDataModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id'},
{ name: 'createTime', type:'date', dateFormat: 'timestamp', convert:function(v,j){ return (v != null?new Date(v):null);}},
{ name: 'discountPercent'},
{ name: 'discountAmount'},
{ name: 'discountOverSalePriceFlag', type: 'boolean'},
{ name: 'minSalePriceTotal'},
{ name: 'maxCount'},
{ name: 'execOrder'},
{ name: 'clearanceIncludedFlag', type: 'boolean'},
{ name: 'relatedProductMinCount'},
{ name: 'promocodeRuleTypeName', mapping: 'promocodeRuleType.friendlyType'},
{ name: 'groupName'},
{ name: 'productTypeId', mapping: 'productType.id', defaultValue: ''},
{ name: 'productTypeName', mapping: 'productType.name', defaultValue: ''},
{ name: 'relatedProductTypeId', mapping: 'relatedProductType.id', defaultValue: ''},
{ name: 'relatedProductTypeName', mapping: 'relatedProductType.name', defaultValue: ''}
],
idProperty: 'id'
});
返回的 JSON 数据:
{totalCount: 1, root: [{"productType": {"name":
...
"relatedProductType":null,
...
"execOrder":0,"id":11}]}