[英]Grief with extJS4 treegrid using custom model and async loading
我只是似乎无法启动树状网格并运行它。 我已经定义了模型,商店和treegrid(如下所示)。 树形网格显示目标内部,数据已异步加载(通过提琴手检查,返回了两行),但是树形网格仅显示了两行带有空单元格。
我尝试调试,并且商店的根节点确实有两个子节点,模型数据在子节点的raw
属性下(某些字段(如也在data
属性中的leaf和iconCls除外)),但是树形网格显示了两个空行,尽管dataIndex指向适当的模型字段。
就像树网格找不到模型定义的字段一样!!?
这是源(我使用沙箱是因为将其集成到salesforce vforce中,salesforce合并字段{!}也是有效的并且可以正确呈现)
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
的请求有效( json_CIChildren?_dc=1329830854458&node=a0NT0000006tYKzMAM
中的parentID
root.id
传播),并返回有效的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"
}
]}
我究竟做错了什么? 为什么treegrid看不到name和recordType字段?
这是因为存储只看到了类似NodeInterface的字段,并且data属性中没有我的自定义数据吗?
我认为问题在于您的模型字段映射不正确。 每个字段的“ id”属性应改为“ name”属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.