You found a bug! We've classified it as TOUCH-4763 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Dec 2007
    Posts
    5
    Vote Rating
    0
    federico.monaldi@gmail.com is on a distinguished road

      0  

    Default Chart listeners don't work if component is destroyed and recreated with same id

    Chart listeners don't work if component is destroyed and recreated with same id


    Hi
    we have some use cases where we create a component containing a chart with some "itemtap" listeners. Then we remove this component from the view (destroying it). Then we recreate the same component, with the same id, but from now on, all chart listeners don' work anymore.
    This is the sample code that recreate the bug,
    first time the chart is created, listeners on chart work, but if you click the toolbar button to remove the chart , and click again on it to re-create it, listeners on the pie don't work anymore.

    Code:
    var createChart = function() {
        return new Ext.chart.PolarChart({
            id           : 'xxx-chart-id', // if this line is commented it works
            title        : 'chart',
            animate      : true,
            interactions : ['rotate'],
            colors       : ["#115fa6", "#94ae0a", "#a61120", "#ff8809", "#ffd13e"],
            store        : {
                fields : ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
                data   : [
                    {'name' : 'metric one', 'data1' : 10, 'data2' : 12, 'data3' : 14, 'data4' : 8, 'data5' : 13},
                    {'name' : 'metric two', 'data1' : 7, 'data2' : 8, 'data3' : 16, 'data4' : 10, 'data5' : 3},
                    {'name' : 'metric three', 'data1' : 5, 'data2' : 2, 'data3' : 14, 'data4' : 12, 'data5' : 7},
                    {'name' : 'metric four', 'data1' : 2, 'data2' : 14, 'data3' : 6, 'data4' : 1, 'data5' : 23},
                    {'name' : 'metric five', 'data1' : 27, 'data2' : 38, 'data3' : 36, 'data4' : 13, 'data5' : 33}
                ]
            },
            series       : [
                {
                    type       : 'pie',
                    labelField : 'name',
                    xField     : 'data3',
                    donut      : 30
                }
            ],
            listeners    : {
                itemtap : function() {
                    console.log('itemtap');
                }
            }
        });
    };
    
    var panel = Ext.Viewport.add({
        xtype  : 'panel',
        layout : 'fit',
        items  : [
            {
                xtype  : 'toolbar',
                docked : 'top',
                title  : 'toolbar',
                items  : [
                    {
                        xtype     : 'button',
                        text      : 'Recreate Chart',
                        listeners : {
                            tap : function() {
                                panel.removeAll(true, false);
                                panel.add(createChart());
    
                                console.warn('Chart recreated');
                            }
                        }
                    }
                ]
            },
            createChart()
        ]
    });
    note that if we don't assign an id to the chart listeners works. but unfortunatly we must ensure it has tha same id.
    Any help is appreciated.
    thanks
    Last edited by mitchellsimoens; 2 Aug 2013 at 10:55 AM. Reason: cleaned up code

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,652
    Vote Rating
    901
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I'm going to open this as a bug as it should technically work.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    9
    Vote Rating
    0
    ljf is on a distinguished road

      0  

    Default Bug still unresolved 1 year later?

    Bug still unresolved 1 year later?


    Quote Originally Posted by mitchellsimoens View Post
    I'm going to open this as a bug as it should technically work.
    In some apps, working with ComponentQuery is a hassle whereas using getCmp is straightforward. It's a pity that this bug is apparently still unresolved in Touch 2-3-1.