这是一个简单的用例,用于存储具有继承性的一对多(甚至一对一)。Ext JS 如何用它的 JSON 阅读器处理这个问题?
以下代码提供了一些伪模型和数据来说明用例:
伪代码示例:
Models:
Car {
model,
year,
color
}
Truck extends Car {
bedLength,
duality
}
Van extends Car {
leftSlideDoor,
rightSlideDoor,
tailGate
}
CarOwner {
name,
cars <Car>
}
Data:
carOwners:
[
{
name: "Sencha",
cars: [
{
color: "Brown",
model: "Mater"
type: "truck",
duality: "false",
bedLength: "10"
},
{
color: "red",
model: "sienna",
type: "van",
tailGate: "true",
leftSlideDoor: "true",
rightSlideDoor: "true"
}
]
}
]
加载数据时,会实例化并加载“正确”类型的 Cars。如何在 Ext JS 中做到这一点?