-
31 Oct 2011 12:14 PM #1
Unanswered: Bug while repopulating the store
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); });
-
1 Nov 2011 4:57 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
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 @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Nov 2011 3:59 PM #3
Unfortunately no, I still get the same error. Do you prefer jsonStore to ArrayStore or use some other solution?Thanks!Luka
-
2 Nov 2011 4:02 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
I personally just use a regular Store
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Nov 2011 4:12 PM #5
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.
-
2 Nov 2011 4:14 PM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3109
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote