简体   繁体   English

使用自定义模型和异步加载的extJS4 treegrid的问题

[英]Grief with extJS4 treegrid using custom model and async loading

I just cannot seem to get the tree grid up and running. 我只是似乎无法启动树状网格并运行它。 I have defined the model, the store and the treegrid (as seen below). 我已经定义了模型,商店和treegrid(如下所示)。 The tree grid shows inside target, the data is loaded async (checked with fiddler, two rows came back) however the treegrid just shows two rows with empty cells. 树形网格显示目标内部,数据已异步加载(通过提琴手检查,返回了两行),但是树形网格仅显示了两行带有空单元格。

I tried debugging and the store's root node indeed has two child nodes, the model data is under child's raw property (except some fields such as leaf and iconCls which are also in data property), yet the tree grid shows two empty rows, despite dataIndex pointing to a proper model field. 我尝试调试,并且商店的根节点确实有两个子节点,模型数据在子节点的raw属性下(某些字段(如也在data属性中的leaf和iconCls除外)),但是树形网格显示了两个空行,尽管dataIndex指向适当的模型字段。

It's like tree grid cannot find the field defined by the model?!? 就像树网格找不到模型定义的字段一样!!?

Here's the source (I am using sandbox because I am integrating this into salesforce vforce, the salesforce merge fields {!} are also valid and render properly) 这是源(我使用沙箱是因为将其集成到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'}
        ]
    });
});​

The request to json_CIChildren?_dc=1329830854458&node=a0NT0000006tYKzMAM was valid (the parentID in root.id got propagated ok) and came back with valid json: 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"
         }
 ]}

What am I doing wrong? 我究竟做错了什么? Why isn't the treegrid seeing name and recordType fields? 为什么treegrid看不到name和recordType字段?

Is this because store only saw NodeInterface-like fields and there is none of my custom data in data property? 这是因为存储只看到了类似NodeInterface的字段,并且data属性中没有我的自定义数据吗?

I think the problem is your model fields aren't mapped right. 我认为问题在于您的模型字段映射不正确。 The "id" property for each field should be the 'name' property instead. 每个字段的“ id”属性应改为“ name”属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM