1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    7
    Vote Rating
    0
    juan1981 is on a distinguished road

      0  

    Default Unanswered: TreePanel with an specific TreeStore

    Unanswered: 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 - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    109
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      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
    juan1981 is on a distinguished road

      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 - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    109
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      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?

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar