Results 1 to 3 of 3

Thread: TreeNode: deselect a node or I want to restrict a tree node from selecting it.

  1. #1
    Sencha User nareshkokkula's Avatar
    Join Date
    Feb 2012
    Posts
    48
    Answers
    1

    Default Answered: TreeNode: deselect a node or I want to restrict a tree node from selecting it.

    Hi..Can some one help me in restricting a tree node to be not selected.I used the following code to deselect tree node in the beforeselect event.but its selecting with a ash colored line... var srcTree = Ext.create('Ext.tree.Panel', { title: 'Source Tree', width: 300, autoScroll: true, animate: true, enableDD: true, ddGroup: 'secondTreeDDGroup', multiSelect: true, containerScroll: true, region: 'center', store: store, viewConfig: { plugins: { ddGroup: 'selDD', ptype: 'treeviewdragdrop', enableDrop: false } }, listeners: { 'select': BeforeSelect } }); function BeforeSelect(rownModel, record, index, eOpts) { if (record.data.text == "Energy foods") { rownModel.deselect(index, true); } }Please help me.Thanks,Deselect Tree Node.jpgNaresh

  2. I added the listeners for my tree control

    listeners: {
    'itemClick': ItemClick,
    'itemmouseleave': ItemClick,
    'itemmousedown': ItemClick,
    'itemmouseenter': ItemClick
    }

    function ItemClick(view, record, item, index, e, eOpts) {
    if (!selectWorkers && record.data.type == "Worker") {
    view.deselect(record);
    }
    }
    This deselects the node.

    Can any one suggests better approach for this

  3. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347

    Default

    You should listen on 'beforeselect' event instead of 'select' event.
    Code:
    var srcTree = Ext.create('Ext.tree.Panel', { 
        title: 'Source Tree', 
        width: 300, 
        autoScroll: true, 
        animate: true, 
        enableDD: true, 
        ddGroup: 'secondTreeDDGroup', 
        multiSelect: true, 
        containerScroll: true, 
        region: 'center', 
        store: store, 
        viewConfig: { 
            plugins: { ddGroup: 'selDD', ptype: 'treeviewdragdrop', enableDrop: false } 
        }, listeners: { 
            'beforeselect': function(rownModel, record){
                return record.get('text') != 'Energy foods';
            } 
        } 
    });

  4. #3
    Sencha User nareshkokkula's Avatar
    Join Date
    Feb 2012
    Posts
    48
    Answers
    1

    Default I found the answer

    I added the listeners for my tree control

    listeners: {
    'itemClick': ItemClick,
    'itemmouseleave': ItemClick,
    'itemmousedown': ItemClick,
    'itemmouseenter': ItemClick
    }

    function ItemClick(view, record, item, index, e, eOpts) {
    if (!selectWorkers && record.data.type == "Worker") {
    view.deselect(record);
    }
    }
    This deselects the node.

    Can any one suggests better approach for this

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
  •