Hybrid View

    You found a bug! We've classified it as EXTJS-6715 . 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
    Feb 2012
    Posts
    215
    Vote Rating
    4
    colin.yates is on a distinguished road

      0  

    Default (4.1) Should store.add respect filters?

    (4.1) Should store.add respect filters?


    Hi,

    I have a memory store which an asynchronous ajax call occasionally adds records to. This store can be configured at run-time with filters and sorts and is backing a grid.

    The problem is that if I add a record (store.add(..)) which doesn't match the current filter it is still displayed on the grid. Calling store.filter() hides it, but it also unfortunately resets any groupings (expanded/collapsed) and scroll co-ordinates.

    It if helps, imagine I am building a grid which display server side log messages. It is updated every N seconds by an Ajax call which manually updates the store. The GUI allows you to filter messages though - maybe you only want to see SEVERE messages for example.

    So my question is, how can I add a record to a (memory) store which is backed by a grid with filters so the grid only shows that item if it matches the current filter without losing the scroll and group state?

    Thanks!

  2. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    215
    Vote Rating
    4
    colin.yates is on a distinguished road

      0  

    Default


    Trawling through the forums again I found: http://www.sencha.com/forum/showthre...-EXTJS-4/page3 which links to http://docs.sencha.com/ext-js/4-1/#%...crollOnRefresh, which seems to work a treat!

    Now to find a corresponding "preserveGroupsOnRefresh"...

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    215
    Vote Rating
    4
    colin.yates is on a distinguished road

      0  

    Default


    More context - this is only a problem if the group plugin is configured "startCollapsed:true" (which isn't the default)

  4. #4
    Sencha - Community Support Team jsakalos's Avatar
    Join Date
    Apr 2007
    Location
    Slovakia
    Posts
    27,521
    Vote Rating
    375
    jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future jsakalos has a brilliant future

      0  

    Default


    Is it solved or you need some assistance?
    Jozef Sakalos, aka Saki

    Education, extensions and services for developers at new http://extjs.eu
    News: Grid Search Plugin, ExtJS 5 Complex Data Binding using MVVM


  5. #5
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    215
    Vote Rating
    4
    colin.yates is on a distinguished road

      0  

    Default


    My query still stands - when calling store.add() on a grid's store, should a record appear on the grid if it doesn't match the filter? My experiments indicate that the record does still appear until store.filter is called.

    To be clear, I have a memory backed store, and a grid with a simple filter of "departmentId"=5. If I add a record {name:'hi-ho',departmentId:10} then it will appear on that grid until I call store.filter(). Is that expected behaviour?

  6. #6
    Sencha Premium Member
    Join Date
    Feb 2012
    Posts
    215
    Vote Rating
    4
    colin.yates is on a distinguished road

      0  

    Default


    The story continues .

    I have found that if I have a record which *does* match a filter and then I update it so that it no longer matches the filter it is still (incorrectly) displayed in the grid, even after a store.filter(). Adding a new record does the right thing, so instead of updating it I remove and re-add it:

    Code:
                var existingRecord = store.getById(newRecord.id);
                if (existingRecord != null) {
                    /*
                    Editing the record updates it and the subsequent store.filter() removes it from view if necessary,
                    however, *new* records which should be in the filter aren't added.
    
    
                    To work around this, delete the existing record and re-add it.
                     */
    //                existingRecord.beginEdit();
    //                var fields = existingRecord.fields;
    //                for (var i = 0; i < fields.length; i++) {
    //                    var key = fields.get(i).name;
    //                    var newValue = newRecord.get(key);
    //                    existingRecord.set(key, newValue);
    //                }
    //                existingRecord.endEdit();
                    store.remove(existingRecord);
                    records.push(newRecord);
                 } else {
                    records.push(newRecord);                
                 }
    ..
    ..
                 store.add(records);
                 store.filter();
    Removing and re-adding is unfortunate as it loses row-selection and isn't "the right thing to do", but I can live with it.

    Should I create a small demo and post as a bug report? I am hesitant as almost certainly the bug is in my code or understanding ....

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi