使用自定义模型和异步加载的extJS4树网格的悲哀
Grief with extJS4 treegrid using custom model and async loading
我似乎无法启动并运行树网格。我已经定义了模型、商店和树网格(如下所示)。树网格显示在目标内部,数据是异步加载的(用fiddler检查,返回了两行),但树网格只显示了两行空单元格。
我尝试了调试,商店的根节点确实有两个子节点,模型数据在子节点的raw
属性下(除了一些字段,如leaf和iconCl,它们也在data
属性中),但树网格显示了两个空行,尽管dataIndex指向了一个合适的模型字段。
这就像树网格找不到模型定义的字段一样?!?
以下是源代码(我使用沙盒,因为我正在将其集成到salesforce vforce中,salesforce-merge字段{!}也是有效的,并且正确呈现)
Ext4.onReady(function() {
var target = '{!$Component.childBlock.childTreeDiv}';
Ext4.define('ConfigurationItem', {
extend: 'Ext4.data.Model',
fields: [
{
id: 'id',
type: 'string'},
{
id: 'name',
type: 'string'},
{
id: 'recordType',
type: 'string'},
{
id: 'ciName',
type: 'string'},
{
id: 'alias',
type: 'string'},
{
id: 'model',
type: 'string'},
{
id: 'status',
type: 'string'},
{
id: 'description',
type: 'string'},
{
id: 'leaf',
type: 'bool'},
{
id: 'iconCls',
type: 'string'}
]
});
var store = Ext4.create('Ext4.data.TreeStore', {
model: 'ConfigurationItem',
root: {
nodetype: 'async',
id: '{!CI__c.Id}',
expanded: true
},
proxy: {
type: 'ajax',
url: 'json_CIChildren',
reader: {
type: 'json',
root: 'children'
}
}
});
tree = Ext4.create('Ext4.tree.Panel', {
width: document.getElementById(target).offsetWidth,
autoHeight: true,
title: 'Child Configuration Items',
collapsible: true,
titleCollapse: true,
renderTo: target,
rootVisible: false,
store: store,
multiSelect: true,
singleExpand: true,
columns: [
{
type: 'treecolumn',
text: 'CI#',
dataIndex: 'name'},
{
text: 'Type',
dataIndex: 'recordType'}
]
});
});
对json_CIChildren?_dc=1329830854458&node=a0NT0000006tYKzMAM
的请求是有效的(root.id
中的parentID
传播正常),并返回有效的json:
{ "children" : [
{
"id": "a0NT0000006tswhMAA",
"name": "CI334593834",
"recordType": "Rack",
"ciName": "Empty rack",
"alias": "",
"model": "",
"status": "",
"description": "",
"leaf": "true",
"iconCls": "x4-ciicon-Rack"
},
{
"id": "a0NT0000006tYKuMAM",
"name": "CI2345234",
"recordType": "Service",
"ciName": "Business Connect - Premium",
"alias": "",
"model": "",
"status": "",
"description": "",
"leaf": "true",
"iconCls": "x4-ciicon-Service"
}
]}
我做错了什么?为什么树网格看不到name和recordType字段?
这是因为商店只看到类似NodeInterface的字段,而在数据属性中没有我的自定义数据吗?
我认为问题是您的模型字段映射不正确。每个字段的"id"属性应改为"name"属性。
相关文章:
- Kendo:我该如何在树视图中创建一个递归的hieiarchy
- 有没有一个javascript图形绘制库可以进行气球树布局
- jqGrid树网格问题
- 如何查找值是否存在于二叉树中
- 设计redux状态树
- EXTJS 5树状网格自定义行css
- 如何在ASP中为用户控件添加Javascript对象网
- 如何操作d3js树布局
- Firefox:点击并更改未附加到文档树中的复选框元素上的事件
- 树视图javascript的反向级别
- 在不添加树节点的情况下从网格拖放到树
- 如何在ExtJs4应用程序上为视图、存储和模型设置自定义文件夹名称
- 在编译阶段后创建新的DOM树,或者继续使用原始修改的DOM
- 将 xml 加载到 extjs4 树存储中
- 使用自定义模型和异步加载的extJS4树网格的悲哀
- Extjs4从树存储中保存file.json
- extjs4中的树面板错误
- extjs4使用PHP和MySQL在树面板中添加复选框
- extjs4:只显示特定id的树面板节点
- Extjs4:使用方法 POST 的树存储