Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-9064 in a recent build.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    974
    Vote Rating
    110
    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

      1  

    Default [4.2.0 RC] Selecting a grid's row with a buffered store causes a JavaScript error

    [4.2.0 RC] Selecting a grid's row with a buffered store causes a JavaScript error


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.2.0 RC
    Browser versions tested against:
    • IE9
    • Chrome
    DOCTYPE tested against:
    • <!DOCTYPE html>
    Description:
    • Selecting a grid's row with a buffered store causes a JavaScript error within the storeHasSelected function.
    Steps to reproduce the problem:
    • Just select any row
    The result that was expected:
    • No error
    The result that occurs instead:
    • An error occurs within the storeHasSelected function.
      Uncaught TypeError: Cannot read property 'length' of undefined

      (Chrome message).
    Test Case:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Selecting a grid's row with a buffered store causes a JavaScript error</title>
    
        <link rel="stylesheet" href="../resources/css/ext-all.css" />
        
        <script src="../ext-all-debug.js"></script>
    
        <!-- A possible fix -->
    
        <!--<script>
            Ext.selection.Model.override({
                storeHasSelected: function(record) {
                    var store = this.store,
                        records,
                        len, id, i;
            
                    if (record.hasId() && /*store.getById(record)*/ store.getById(record.getId())) {
                        return true;
                    } else {
                        records = store.data.items;
                        len = records.length;
                        id = record.internalId;
                
                        for (i = 0; i < len; ++i) {
                            if (id === records[i].internalId) {
                                return true;
                            }
                        }
                    }
                    return false;
                }    
            });
        </script>-->
    
        <script>
            Ext.onReady(function () {
                var data = [],
                    i;
    
                for (i = 0; i < 5000; i++) {
                    data[i] = { id: "id" + i };
                }
    
                Ext.create("Ext.grid.Panel", {
                    renderTo: Ext.getBody(),
                    height: 500,
                    store: {
                        buffered: true,
                        pageSize: 5000,
                        fields: [{
                            name: "id"    
                        }],
                        data: data
                    },
                    columns: [{
                        text: "id",
                        dataIndex: "id"
                    }],
                    selType: "checkboxmodel"
                });
            });
        </script>
    </head>
    <body>
    
    </body>
    </html>


    HELPFUL INFORMATION


    Possible fix:
    • Not sure it is correct.
    Code:
    Ext.selection.Model.override({
        storeHasSelected: function(record) {
            var store = this.store,
                records,
                len, id, i;
            
            if (record.hasId() && /*store.getById(record)*/ store.getById(record.getId())) {
                return true;
            } else {
                records = store.data.items;
                len = records.length;
                id = record.internalId;
                
                for (i = 0; i < len; ++i) {
                    if (id === records[i].internalId) {
                        return true;
                    }
                }
            }
            return false;
        }    
    });
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,795
    Vote Rating
    834
    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


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    974
    Vote Rating
    110
    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


    Thank you, Mitchell.
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  4. #4
    Sencha User
    Join Date
    Mar 2013
    Posts
    3
    Vote Rating
    0
    iorlas is on a distinguished road

      0  

    Default


    EXTJSIV-9064 is in "Bugs Fixed" of 4.2.0.663 version, but it is not fixed. I still have this problem.
    Also, I have problem with models w/o id field. store.data.items is undefined.

  5. #5
    Sencha User
    Join Date
    Mar 2013
    Posts
    3
    Vote Rating
    0
    iorlas is on a distinguished road

      0  

    Default


    Basicly I don't even understand purpose of storeHasSelected function. Store items are removed before storeHasSelected will be called. So, we can't really search store for any records.
    For example, with Daniil fixed code, it gives this error:
    Code:
    Uncaught Ext.data.Store.getById(): getById called for ID that is not present in local cache
    Because store contains nothing in the time of findBy call.

  6. #6
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    974
    Vote Rating
    110
    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


    A little time after reporting this bug I saw it was marked as FIXED. But, in a few moments it became OPEN again. Probably, it was marked fixed accidentally or a quick fix was rejected. Likely, it went to Release Notes automatically after marking the thread FIXED and noone removed it from there.
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  7. #7
    Sencha User
    Join Date
    Nov 2011
    Posts
    4
    Vote Rating
    0
    pedrobaracho is on a distinguished road

      0  

    Default Another suggestion of fix

    Another suggestion of fix


    I am also affected by this bug in ExtJS 4.2.0.663 and I have implemented the following fix:

    Code:
        Ext.override(Ext.selection.Model, {
            storeHasSelected: function(record) {
                var store = this.store,
                    records,
                    len, id, i;
                
                if (record.hasId() && store.getById(record)) {
                    return true;
                } else {
                    records = store.data.items;
                    len = records ? records.length : 0;
                    id = record.internalId;
                    
                    for (i = 0; i < len; ++i) {
                        if (id === records[i].internalId) {
                            return true;
                        }
                    }
                }
                return false;
            }
        });
    
    Cheers,
    Pedro
    Last edited by pedrobaracho; 16 Apr 2013 at 11:33 AM. Reason: adding extjs version to the post

  8. #8
    Sencha User
    Join Date
    Mar 2010
    Posts
    24
    Vote Rating
    3
    ElCondor1969 is on a distinguished road

      0  

    Default


    Hi Pedro.

    In your fix you used:

    Code:
    records = store.data.items;
    But if the store is buffered, you get an error, because in that case store.data is a PageMap object and not a MixedCollection object and PageMaps don't have the items property.

    Bye.

    Sergio.

  9. #9
    Sencha User
    Join Date
    Mar 2012
    Posts
    4
    Vote Rating
    0
    ipbs is on a distinguished road

      0  

    Default


    Don't know if it can help, but I solved this problem with a small work-around :
    I've put the selection code in a 'aftrerrender' listener, so i'm sure the row exists when I select it.

    Code:
           my_gridpanel.addListener('afterrender', function () {
             my_gridpanel.getSelectionModel().select(0);
           });

  10. #10
    Sencha User
    Join Date
    Nov 2011
    Posts
    4
    Vote Rating
    0
    pedrobaracho is on a distinguished road

      0  

    Default


    Hi Sergio,

    in my fix I used:

    Code:
    records = store.data.items;
    len = records ? records.length : 0;
    When the store is buffered, store.data.items evals to undefined, which fails the following check, leaving len = 0.

    This fix works for me, because my buffered-store records always have an id property and I could pretty much remove everything on the else condition and write "return false".

    If you dont have an id property on your models though, using this fix would cause a bug, because your records will never be identified as selected.

    Cheers,

    Pedro.

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