Results 1 to 2 of 2

Thread: event handler triggers wrong function

  1. #1
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    95

    Default event handler triggers wrong function

    Hello...
    I have two tree panels ,they share the same stores, but that's all..they don't have any common identifier
    I have defined for each one a different "itemexpand" handler... however, they both trigger the same function, more accurately
    this is tree1
    Code:
                                                    {                                                    xtype: 'treepanel',
                                                        height: 410,
                                                        id: 'c_Att1',
                                                        padding: 5,
                                                        width: 260,
                                                        title: 'Showing all attributes Pages',
                                                        store: 'c_AttsTree',
                                                        viewConfig: {
    
    
                                                        },
                                                        listeners: {
                                                            select: {
                                                                fn: me.onC_Att1Select,
                                                                scope: me
                                                            },
                                                            itemclick: {
                                                                fn: me.onC_Att1ItemClick,
                                                                scope: me
                                                            },
                                                            itemexpand: {
                                                                fn: me.onC_Att1ItemExpand,
                                                                scope: me
                                                            }
                                                        }
                                                    }
    and this is tree 2
    Code:
    {                    xtype: 'treepanel',
                        height: 380,
                        id: 'win_Att1',
                        width: 280,
                        store: 'c_AttsTree',
                        x: 5,
                        y: 5,
                        viewConfig: {
    
    
                        },
                        listeners: {
                            itemexpand: {
                                fn: me.onWin_Att1ItemExpand,
                                scope: me
                            },
                            itemclick: {
                                fn: me.onWin_Att1ItemClick,
                                scope: me
                            }
                        }
                    }
    the thing is...that for the second tree...both C_Att1ItemExpand and Win_Att1ItemClick are invoked and in that order...when I only expanded the second tree's root

    I checked with the debugger and expanding tree2's root invokes onC_Att1ItemExpand

    any ideas???????

    Thank you

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    This is because since you are sharing the same store, when you make a change in one view, all views using that store will reflect the change. For the tree, the store actually holds the expand/collapse state so that is why the other is firing it also.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •