extjs - 如何在 Extjs 的组合框中传递树存储
问题描述
我有一个组合框,它需要一个树店作为它的商店。我试过下面的代码,但它不起作用。
Ext.define('DemoGroupCombo', {
extend: 'Ext.data.TreeStore',
fields: ['text', 'value'],
proxy: {
type: 'rest',
url: '../SamplePaging/GetComboTree',
//data: groupStoreData,
reader: {
type: 'json',
rootProperty: 'children'
}
}
});
来自 api 的预期 json 结果:
var groupStoreData =
//new Ext.data.TreeStore({
// root:
{
expanded: true, children: [
{
//checked: false, text: "All", expanded: true, children: [
// {
checked: false, text: "Numbers", expanded: true, children: [
{ checked: false, text: '1', value: '1', leaf: true },
{ checked: true, text: '2', value: '2', leaf: true },
{ checked: false, text: '3', value: '3', leaf: true },
{
checked: false, text: '4', value:'4', leaf: true
}
]
}
]
//}]
}
组合框:
{
xtype: 'combobox',
selModel: {
selType: 'checkboxmodel'
},
queryMode: 'local',
displayField: 'text',
valueField: 'value',
store: { type: 'DemoGroupCombo' }
}
现在我收到此错误消息:
错误:[Ext.createByAlias] 无法识别的别名:store.DemoGroupCombo
解决方案
您需要为商店指定别名:
Ext.define('DemoGroupCombo', {
extend: 'Ext.data.TreeStore',
alias: 'store.DemoGroupCombo',
fields: ['text', 'value'],
proxy: {
type: 'rest',
url: '../SamplePaging/GetComboTree',
//data: groupStoreData,
reader: {
type: 'json',
rootProperty: 'children'
}
}
});
推荐阅读
- realm - Keyclock-gatekeeper/louketo-proxy 事件未立即传播到所有客户端
- node.js - 用于 PDF 的 puppeteer 的服务器端渲染或用于受保护/安全站点的 Angularjs 类型应用程序的图像屏幕截图(推送 dom
- flutter - Flutter - 如何为平台(Android、iOS、Web)使用条件编译?
- sharepoint - Graph API:如果驱动器未知,则按 ID 获取 Sharepoint 驱动器项
- javascript - 反应大日历根本不显示或加载
- coq - Coq 自动策略失败
- bash - 如何在命令行上强制解释为关键字而不是别名?
- java - 使用 csv 文件时输出错误
- powerbi - 如何引用 DAX 变量的列?
- neo4j - 如何使 Neo4J Enterprise 备份工作?