extjs将平面数据转换为treestore
我有RESTAPI,它以这种形式提供数据extjs将平面数据转换为treestore,extjs,extjs4.2,treestore,Extjs,Extjs4.2,Treestore,我有RESTAPI,它以这种形式提供数据 <plans> <plan id="0" title="Title 1" planGroup="group1"/> <plan id="1" title="Title 2" planGroup="group1"/> <plan id="2" title="Title 3" planGroup="group2"/> <plan id="3" title="Title 4"
<plans>
<plan id="0" title="Title 1" planGroup="group1"/>
<plan id="1" title="Title 2" planGroup="group1"/>
<plan id="2" title="Title 3" planGroup="group2"/>
<plan id="3" title="Title 4" planGroup="group3"/>
</plans>
我需要像这样以树状结构显示这些数据
├── group1
│ └── Title1
│ └── Title2
└── group2
│ └── Title3
├── group3
│ └── Title4
root: {
expanded: true,
text: 'root',
children: [
{ name: 'group1', expanded: true,
children: [
{ name: "Title1", leaf: true },
{ name: "Title2", leaf: true}
]
},
{ name: 'group2', expanded: true,
children: [
{ name: "Title3", leaf: true }
]
},
{ name: 'group3', expanded: true,
children: [
{ name: "Title4", leaf: true}
]
}
]
}
基本上,我需要用这样的数据创建TreeStore
├── group1
│ └── Title1
│ └── Title2
└── group2
│ └── Title3
├── group3
│ └── Title4
root: {
expanded: true,
text: 'root',
children: [
{ name: 'group1', expanded: true,
children: [
{ name: "Title1", leaf: true },
{ name: "Title2", leaf: true}
]
},
{ name: 'group2', expanded: true,
children: [
{ name: "Title3", leaf: true }
]
},
{ name: 'group3', expanded: true,
children: [
{ name: "Title4", leaf: true}
]
}
]
}
但我不知道如何配置TreeStore以及要覆盖哪些函数以获得所需的结果。您是否尝试过使用分组的普通网格是否足够?如果您想将平面列表转换为树,则必须手动将加载到普通存储中的所有数据逐模型、逐记录复制到树存储中,并在此过程中手动还原树信息。以防升级到ExtJS 6::)实际上,您可能需要借用ExtJS 6中的treestore方法,该方法将平面节点数组转换为树结构。@scebotari请不要链接到
devdocs.local
,我们将无法跟踪此类链接。您是否尝试过使用分组的普通网格是否足够?如果您想将平面列表转换为树,则必须手动将加载到普通存储中的所有数据逐模型逐记录复制到树存储中,并在此过程中手动还原树信息。以防升级到ExtJS 6::)实际上,您可能需要借用ExtJS 6中的treestore方法,该方法将平面节点数组转换为树结构。@scebotari请不要链接到devdocs.local
,我们将无法跟踪此类链接。