Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    627
    Vote Rating
    10
    zombeerose will become famous soon enough zombeerose will become famous soon enough

      0  

    Post Ext.destroy should be expanded for stores

    Ext.destroy should be expanded for stores


    REQUIRED INFORMATION


    Ext version tested:
    • Ext 4.0 rev 4

    Browser versions tested against:
    • FF5

    Description:
    • I was under the impression that I could use Ext.destroy(args) to remove references to stores from within a component because the docs state "any subclass of Ext.util.Observable can be passed in." However, the function destroy() for a store is related to the CRUD action -- not cleanup, which is what destroyStore() does. This multiple use of 'destroy' is confusing.

    Steps to reproduce the problem:
    • Run the code. Click the Close button.

    The result that was expected:
    • Destruction of store.

    The result that occurs instead:
    • Destruction of records instead.

    Test Case:

    Code:
    Ext.define('ForumThread', {
        extend: 'Ext.data.Model',
        fields: [
            'title', 'forumtitle', 'forumid', 'author',
            {name: 'replycount', type: 'int'},
            {name: 'lastpost', mapping: 'lastpost', type: 'date', dateFormat: 'timestamp'},
            'lastposter', 'excerpt', 'threadid'
        ],
        idProperty: 'threadid'
    });
    
    Ext.define('Ext.ux.StorePanel',{
        extend: 'Ext.panel.Panel',
        initComponent: function(){
            Ext.apply(this, {
                buttons: [{ text: 'Close', handler:function(){ this.destroy(); }, scope:this }],
                html: 'Example of the improper destruction of a store'
            });
            
            this.callParent(arguments);
            
            this.store = Ext.create('Ext.data.Store', {
                autoLoad: true,
                pageSize: 50,
                model: 'ForumThread',
                remoteSort: true,
                proxy: {
                    type: 'jsonp',
                    url: 'http://www.sencha.com/forum/topics-browse-remote.php',
                    reader: {
                        root: 'topics',
                        totalProperty: 'totalCount'
                    },
                    simpleSortMode: true
                },
                sorters: [{
                    property: 'lastpost',
                    direction: 'DESC'
                }]
            });
            
            console.log('init',this.store);
        },
    
        onDestroy: function(){
            Ext.destroyMembers(this,'store');
            this.callParent(arguments);
        }
    });
    
    var c = Ext.create('Ext.ux.StorePanel',{
        renderTo:Ext.getBody(),height:400
    });


    HELPFUL INFORMATION


    Screenshot or Video:
    • none

    See this URL for live test case: http://


    Debugging already done:
    • none

    Possible fix:
    • Code:
          destroy: function() {
              var ln = arguments.length,
              i, arg;
      
              for (i = 0; i < ln; i++) {
                  arg = arguments[i];
                  if (arg) {
                      if (Ext.isArray(arg)) {
                          this.destroy.apply(this, arg);
                      }
                      else if (arg.isStore) {
                          arg.destroyStore();
                      }
                      else if (Ext.isFunction(arg.destroy)) {
                          arg.destroy();
                      }
                      else if (arg.dom) {
                          arg.remove();
                      }
                  }
              }
          }

    Additional CSS used:
    • only default ext-all.css

    Operating System:
    • WinXP Pro

  2. #2
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    627
    Vote Rating
    10
    zombeerose will become famous soon enough zombeerose will become famous soon enough

      0  

    Default


    The bindStore function of Ext.view.AbstractView is an example of an incorrect call to destroy vs destroyStore...

    Code:
            bindStore : function(store, initial) {
                var me = this;
        
                if (!initial && me.store) {
                    if (store !== me.store && me.store.autoDestroy) {
                        me.store.destroy();
                    }
    ...
    Shouldn't this be destroyStore() instead?

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    627
    Vote Rating
    10
    zombeerose will become famous soon enough zombeerose will become famous soon enough

      0  

    Default


    Has anybody reviewed this?

    It appears the same issue with destroy vs destroyStore exists within:
    * Ext.chart.Chart
    * Ext.selection.Model
    * Ext.toolbar.Paging

    The store must be configured as autoDestroy:true.

  4. #4
    Ext JS Premium Member
    Join Date
    Mar 2008
    Location
    Phoenix, AZ
    Posts
    627
    Vote Rating
    10
    zombeerose will become famous soon enough zombeerose will become famous soon enough

      0  

    Default


    bump

  5. #5
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    974
    Vote Rating
    108
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    I think the issue with an AbstractView bindStore has been resolved, but Ext.destroy() still doesn't support destroying stores. I reported it here.
    http://www.sencha.com/forum/showthread.php?262480
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

Thread Participants: 1