Results 1 to 6 of 6

Thread: Bug while repopulating the store

  1. #1
    Sencha User
    Join Date
    Oct 2011
    Posts
    10
    Vote Rating
    0
      0  

    Default Unanswered: Bug while repopulating the store

    Hello. I have recently been asked to help out on a project that involves Ext JS, so I starting playing around with it and discovered the following bug. Not sure if this is a legitimate bug or just me doing something wrong. Basically, on page load I populate the panel with values and display them. Upon clicking on any of those fields in the view, the store should get emptied out and populated with a new set of values. All the code is listed below. However, once I removeAll() and do add(), even though everything works and view shows new values, I always get this error message:"Uncaught TypeError: Cannot read property 'internalId' of undefined" happening on this line: store.add(newData).
    Any idea what might be causing it? I'm using Ext JS 4. Thank you! Luka
    Code:
    var arrayData = [
        ['Jay Gar','MD'],
        ['Aaron Baker','CA'],
        ['Susan Smith','NY'],
        ['Mary Stein','KT'],
        ['John Zalupic','WA'],
    ];
    
    var store = Ext.create('Ext.data.ArrayStore',{
        data: arrayData,
        fields: ['personName', 'state']
    });
    
    var grid = Ext.create('Ext.grid.Panel', {
        title: 'first grid',
        renderTo: Ext.getBody(),
        authoHeight:true,
        width: 250,
        store: store,
        autoScroll: true,
        columns: [
            { header: 'name', dataIndex: 'personName' },
            { header: 'st', dataIndex: 'state', sortable: false }
        ]
    });
    
    grid.getSelectionModel().on('selectionchange', function(sm, selectedRecord){
        var newData = [
            ['Poka Boka', 'VK'],
            ['Choko Mok', 'CA']
        ];      
    
        store.removeAll();
        store.add(newData);    
    });





  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,317
    Answers
    3881
    Vote Rating
    1291
      0  

    Default

    I personally don't like ArrayStore but does this give you an error when you add data like this:

    Code:
        var newData = [
            { personName : 'Poka Boka', state : 'VK'},
            { personName : 'Choko Mok', state : 'CA'}
        ];
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
    Oct 2011
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Unfortunately no, I still get the same error. Do you prefer jsonStore to ArrayStore or use some other solution?Thanks!Luka

  4. #4
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,317
    Answers
    3881
    Vote Rating
    1291
      0  

    Default

    I personally just use a regular Store
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

  5. #5
    Sencha User
    Join Date
    Oct 2011
    Posts
    10
    Vote Rating
    0
      0  

    Default

    A user at Stackoverflow told me that add method expects records and I feed it an array and suggested I create a set of records to add using store.recordType. Is this a valid point, and if so, what's the Ext 4 version of recordType? I can't find recordType in documentation.

    thank you.

  6. #6
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,317
    Answers
    3881
    Vote Rating
    1291
      0  
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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.

Tags for this Thread

Posting Permissions

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