Results 1 to 3 of 3

Thread: Tree Not Loading Nodes On Demand

  1. #1
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    16
    Answers
    1

    Default Answered: Tree Not Loading Nodes On Demand

    I'm trying to setup a tree panel to load child nodes on demand (when a non-leaf node is expanded). I'm using Ext JS 4.2.2-commercial. The children of the root node are loaded correctly, but the TreeStore.load method is not called when those nodes are expanded. Here's what the TreePanel config looks like:
    Code:
    {
                xtype: 'treepanel',
                id: 'labTree',
                store: 'LabTreeStore',
                singleExpand: true,
                displayField: 'Name'
    }
    TreeStore config:
    Code:
    Ext.define('LabData.store.LabTreeStore', {
        extend: 'Ext.data.TreeStore',
        storeId: 'LabTreeStore',
        autoLoad: false,
        model: 'LabData.model.LabTreeNode',
        nodeParam: 'Oid',
        root: {
            expanded: false,
            Name: 'Laboratories',
            Oid: null
        },
        proxy: {
            type: 'WindchillProxy',
            api: {
                read: 'servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml'
            },
            reader: {
                type: 'WindchillXml',
                group: 'Children'
            }
        }
    });
    WindchillProxy is a type of AJAX proxy, and WindchillXml is a type of XML reader.

    TreeModel config:
    Code:
    Ext.define('LabData.model.LabTreeNode', {
        extend: 'Ext.data.TreeModel',
        requires: ['LabData.data.proxy.WindchillProxy'],
        idProperty: 'Oid',
        fields: [{
            name: 'Oid'
        }, {
            name: 'parentId',
            mapping: 'ParentOid'
        }, {
            name: 'Name'
        }, {
            name: 'Number'
        }, {
            name: 'Description'
        }, {
            name: 'DocClass'
        }, {
            name: 'DocType'
        }, {
            name: 'expandable',
            type: 'boolean',
            defaultValue: true
        }, {
            name: 'expanded',
            type: 'boolean',
            defaultValue: false
        }, {
            name: 'leaf',
            type: 'boolean',
            defaultValue: false
        }]
    });
    The initial load request is sent to "...servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml?_dc=...&Oid=", and it returns the following:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
     <wc:COLLECTION xmlns:wc="http://www.ptc.com/infoengine/1.0">
     <Children NAME="Children" TYPE="Object" STATUS="0">
     <wc:INSTANCE CLASS="Data">
         <Oid>VR:wt.doc.WTDocument:1348534131</Oid>
         <Name>Test Lab 1</Name>
         <Description>...</Description>
         <DocClass>...</DocClass>
         <DocType>...</DocType>
         <Number>...</Number>
       </wc:INSTANCE>
     </Children>
     </wc:COLLECTION>
    I'm expecting a request to be sent to "...servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml?_dc=...&Oid=VR:wt.doc.WTDocument:1348534131" when that node is expanded, but no request is made. What am I missing?

  2. Quote Originally Posted by Carlos_hb View Post
    I once tried one and had some different configurations, in the root config from the treestore, i have expanded true and other parameter called loaded: true.I don't think that will change but it's the only thing you have different from meHope to help
    Thanks for your help. I have it working now. There is a problem in the custom WindchillXml reader code (not posted), which wasn't designed to be used by a TreeStore. I replaced the TreeStore config with this:
    Code:
    Ext.define('LabData.store.LabTreeStore', {
        extend: 'Ext.data.TreeStore',
        storeId: 'LabTreeStore',
        autoLoad: false,
        model: 'LabData.model.LabTreeNode',
        nodeParam: 'Oid',
        root: {
            expanded: false,
            Name: 'Laboratories',
            Oid: null
        },
        proxy: {
            type: 'WindchillProxy',
            api: {
                read: 'servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml'
            },
            reader: {
                type: 'xml',
                root: 'Children',
                record: '[CLASS=Data]'
            }
        }
    });
    The on-demand loading is working now.

  3. #2
    Sencha User
    Join Date
    May 2012
    Posts
    15
    Answers
    1

    Default

    I once tried one and had some different configurations, in the root config from the treestore, i have expanded true and other parameter called loaded: true.I don't think that will change but it's the only thing you have different from meHope to help

  4. #3
    Sencha Premium Member
    Join Date
    Sep 2012
    Posts
    16
    Answers
    1

    Default

    Quote Originally Posted by Carlos_hb View Post
    I once tried one and had some different configurations, in the root config from the treestore, i have expanded true and other parameter called loaded: true.I don't think that will change but it's the only thing you have different from meHope to help
    Thanks for your help. I have it working now. There is a problem in the custom WindchillXml reader code (not posted), which wasn't designed to be used by a TreeStore. I replaced the TreeStore config with this:
    Code:
    Ext.define('LabData.store.LabTreeStore', {
        extend: 'Ext.data.TreeStore',
        storeId: 'LabTreeStore',
        autoLoad: false,
        model: 'LabData.model.LabTreeNode',
        nodeParam: 'Oid',
        root: {
            expanded: false,
            Name: 'Laboratories',
            Oid: null
        },
        proxy: {
            type: 'WindchillProxy',
            api: {
                read: 'servlet/IE/tasks/ext/TACOM/labdata/readChildren.xml'
            },
            reader: {
                type: 'xml',
                root: 'Children',
                record: '[CLASS=Data]'
            }
        }
    });
    The on-demand loading is working now.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •