Results 1 to 4 of 4

Thread: TreePanel with an specific TreeStore

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    7
    Vote Rating
    0
      0  

    Default TreePanel with an specific TreeStore

    Hi all,

    I've got the flollowing issue in a project with C#and ExtJs 4.1:

    I'm building a TreePanel with data of people but I don't know how to define the model of it without defineing : leaf, cls and text attributes. I wan't that "Name" would be the node text of each node .

    My model is defined as following:

    Code:
    Ext.define('People', {
         extend: 'Ext.data.Model',
         fields: [
             {name: 'Name', type: 'string'},
             {name: 'Surname',  type: 'string'},
             {name: 'Email',       type: 'string'}
             {name: 'BirthDate',  type: 'string'}
         ]
     });
    My TreeStore (for the moment with static data, but it will be load from an ajax call to the server that will return a list of server person model). Obviously I don't want to define leaf, text and cls attributes in my server model:

    Code:
    Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            children: [
                {"Name":"Juan", "Surname":"Hoz", "Email": "user@domain.com", "BirthDate":"19801205"},
                {"Name":"Marta", "Surname":"Hoz", "Email": "user2@domain.com", "BirthDate":"19831210"}
        }
    });
    My TreePanel is defined as following:

    Code:
    Ext.create('Ext.tree.Panel', {
        id: 'treePersonId',
        store: mystore,
        hideHeaders: true,
        rootVisible: false,
        title: 'Persons',
        collapsible: true,
        resizable:true
    });
    Can anyone helps me to find the correct way to do this?

    Thank you very much,

    Juan

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    116
      0  

    Default

    Try this:
    Code:
    Ext.create('Ext.tree.Panel', {
        id: 'treePersonId',
        store: mystore,
        hideHeaders: true,
        rootVisible: false,
        title: 'Persons',
        collapsible: true,
        resizable:true,
        columns: [{
            xtype: 'treecolumn',
            header: 'Name',
            dataIndex: 'Name'
        }]
    });

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    7
    Vote Rating
    0
      0  

    Default

    Thank you very much.

    We are in the correct way but I still have a problem. All nodes are not consider leaves and in this TreePanel all nodes would be leaves ("leaf":true). How can I set all of them to leaf and how can I set the same icon for all nodes?

    The only way I know is to do it manually usign a listener (add or datachange), but when de Tree is loaded ther first time?

    Thank you very much.

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    116
      0  

    Default

    You can listen for 'load' event on store and then scan through all of its records (starting from root) and set 'icon', 'leaf',... But why don't you define fields such as 'leaf', 'icon' and set these in your data?

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
  •