Results 1 to 5 of 5

Thread: store load event seems to fire before filter on localstorage

    You found a bug! We've classified it as TOUCH-4343 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha Premium Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    591

    Default store load event seems to fire before filter on localstorage

    Let me jump straight into some code. The model has a localstorage proxy.

    Code:
    Ext.create('Ext.data.Store', {
                model: 'MyApp.model.MyModel',
                autoLoad: true,
                pageSize: 1000,
                filters: [
                    // any kind of filter in here
                ],
    
    
                listeners: {
                    scope: this,
                    load: function (store) {
                        console.log(store.getCount());
    
    
                        Ext.defer(function () { console.log(store.getCount()); }, 1, this);
    
    
                    }
                }
            });
    The first console.log outputs the total number of records in the localstorage for this model. The second, the number of filtered records. I'd say a developer would expect the second result immediately without having to defer to let the filter run - especially since there is no filter event on Ext.data.Store, and in the docs the getCount method explicitly says this count does not include filtered records: "Gets the number of cached records. Note that filtered records are not included in this count. If using paging, this may not be the total size of the dataset."

    This is also changing the behaviour compared to the sqlite proxy. I've seen on that proxy that the sql query changes depending on the filter defined on the store. Therefore the same example is filtered from the start - the all index of the data object has the same as the items one immediately after load.

    I would throw my two cents towards the sqlite proxy behaviour. This is what I'd expect as the developer and I really dislike that all localstorage store loads put every single record of that type into the store and then filter. I don't want these records hanging around in the memory - in the above example, the filter is on the store from the start! Or perhaps an additional config, something that works similarly to remoteFilter, might be of use here?
    ExtJS Websql/Sqlite/IndexedDB/Dynamic proxies: https://github.com/shepsii/extjs-db-proxies

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

    Default

    I'm going to open a bug to see what we can do about this.

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2012
    Location
    London, UK
    Posts
    591

    Default

    Thanks Mitchell, appreciate it.

    In using the sql proxy a bit more, I've also discovered that it fails on models with array or object fields. This is another issue where there I guess there should be more consistency between the localstorage and sql behaviors.

    I've written an override that handles these fields by encoding them to json in the database. It's a little messy but I'm happy to share with anyone who would like this functionality.
    ExtJS Websql/Sqlite/IndexedDB/Dynamic proxies: https://github.com/shepsii/extjs-db-proxies

  4. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    18

    Default

    Was this issue resolved?

  5. #5
    Sencha Premium User
    Join Date
    Oct 2016
    Posts
    24

    Default

    4 years and it's still a bug, great job sencha

Posting Permissions

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