-
27 Apr 2012 4:50 AM #1
[4.1] Uncaught TypeError with Ext.selection.Model
[4.1] Uncaught TypeError with Ext.selection.Model
Hi all
this part of the code (Ext.selection.Model) creates an Uncaught TypeError: Cannot read property 'id' of undefined later in the execution.
It happens when 'records' is a number for which no records exist in the store. We should test the existence of record being passed to doSingleSelect and doMultiSelect :Code:doSelect: function(records, keepExisting, suppressEvent) { var me = this, record; if (me.locked || !me.store) { return; } if (typeof records === "number") { records = [me.store.getAt(records)]; records = me.store.getAt(records); // this would be better, instead of above } if (me.selectionMode == "SINGLE" && records) { record = records.length ? records[0] : records; me.doSingleSelect(record, suppressEvent); } else { me.doMultiSelect(records, keepExisting, suppressEvent); } },
if(record) {me.doSingleSelect ...
Cheers,
C.
-
1 May 2012 8:03 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
So you are trying to select something that doesn't exist?
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 May 2012 1:42 PM #3
Well, I think the framework is trying to somehow ...
This type of scenario occurs for instance when user tries to navigate though a boundlist for which the store is empty. At some point in Ext.selection.DataViewModel, we have :
This leads to doSelect function above with records argument = 0, and hence the problem:Code:onNavKey: function(step) { step = step || 1; var me = this, view = me.view, selected = me.getSelection()[0], // in this case, no selection numRecords = me.view.store.getCount(), idx; if (selected) { idx = view.indexOf(view.getNode(selected)) + step; } else { idx = 0; } if (idx < 0) { idx = numRecords - 1; } else if (idx >= numRecords) { idx = 0; } me.select(idx);// so idx = 0 at this point ! }
The real problem in this case is thatCode:me.doSingleSelect(record, suppressEvent) // here record == undefined
if (me.selectionMode == "SINGLE" && records)will always be true.
Thanks for looking into this,
C.


Reply With Quote