1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    59
    Vote Rating
    0
    extjser12 is on a distinguished road

      0  

    Default Answered: Select first children of TreePanel

    Answered: Select first children of TreePanel


    Hello together

    Why doesn't the following code work in Ext JS 4.1 final?
    Code:
    Ext.onReady(function() {
        var store = Ext.create('Ext.data.TreeStore', {
            root: {
                expanded: true,
                children: [
                    { text: "Item 1", leaf: true },
                    { text: "Item 2", leaf: true }
                ]
            }
        });
    
    
        var tree = Ext.create('Ext.tree.Panel', {
            store: store,
            rootVisible: false
        });
    
    
        Ext.create('Ext.container.Viewport', {
            layout: 'border',
            items: [{
                region: 'west',
                collapsible: true,
                title: 'TreePanel',
                width: 200,
                split: true,
                layout: 'fit',
                items: [
                    tree
                ]
            }]
        });
        tree.selectPath(tree.getRootNode().getChildAt(0).getPath());
    });
    In Ext JS 4 RC3 the above code works as expected.

    How can I achieve that the 1st children in the TreePanel will be selected in Ext JS 4.1 final?

    Thanks for your help!

    Kind regards, extjser12

  2. Some solutions for your case:
    1. Specifying a field for getPath() and setPath(). One thing to remember is that this field should make the path unique. So it's better to define id for each node and use that field (default field is determined by idProperty)
    Code:
    tree.selectPath(tree.getRootNode().getChildAt(0).getPath('text'), 'text');
    2. Use SelectionModel
    Code:
    tree.getSelectionModel().select(tree.getRootNode().getChildAt(0));

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    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


    Some solutions for your case:
    1. Specifying a field for getPath() and setPath(). One thing to remember is that this field should make the path unique. So it's better to define id for each node and use that field (default field is determined by idProperty)
    Code:
    tree.selectPath(tree.getRootNode().getChildAt(0).getPath('text'), 'text');
    2. Use SelectionModel
    Code:
    tree.getSelectionModel().select(tree.getRootNode().getChildAt(0));

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi