1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    1
    Vote Rating
    0
    niteshgoel is on a distinguished road

      0  

    Default Unanswered: remove clickability of tree nodes

    Unanswered: remove clickability of tree nodes


    Hi,

    How can i remove the click of the tree nodes (i.e i dont want them to be clickable) and selectively apply clickability on tree nodes.


    Thanks.

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    4,789
    Answers
    357
    Vote Rating
    167
    slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold slemmon is a splendid one to behold

      0  

    Default


    Use treepanel's beforeselect event (see example below). In the beforeselect handler you can evaluate the record to see if you want it to be selectable. In this example I return true if the record is not a leaf.

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        root: {
            expanded: true,
            children: [
                { text: "detention", leaf: true },
                { text: "homework", expanded: true, children: [
                    { text: "book report", leaf: true },
                    { text: "alegrbra", leaf: true}
                ] },
                { text: "buy lottery tickets", leaf: true }
            ]
        }
    });
    
    
    Ext.create('Ext.tree.Panel', {
        title: 'Simple Tree',
        width: 200,
        height: 150,
        store: store,
        rootVisible: false,
        renderTo: Ext.getBody()
        , listeners: {
            beforeselect: function (selModel, record) {
                return !record.isLeaf();
            }
        }
    });

Thread Participants: 1

Tags for this Thread