PDA

View Full Version : Get Combo Selected Text from Backing Store Fails (getById())



Chris55
10 Oct 2009, 1:56 PM
I have looked this over for the past hour and can't see what the issue is. I am trying to get the display text of the combo box through its backing store (local). It seems that method Ext.data.ArrayStore().getById(string) is not working correctly. Here is the sample code.



Ext.ns('Application.Localdata');

Application.Localdata.Arrays = function() {
var Modules = [
['1', 'One']
,['2', 'Two']
,['3', 'Three']
];

var ModuleArray;

return {
getModules: function() {
if (ModuleArray == null) {
ModuleArray = new Ext.data.ArrayStore({
fields: ['id', 'module']
,data: Modules
})
}
return ModuleArray;
}
,getModuleText: function(id){
alert(id);
return ModuleArray.getById(id).get('module'); // ModuleArray exists but method getById fails!
}
}
}();

var dummyAS = Application.Localdata.Arrays.getModules();
var selectedText = Application.Localdata.Arrays.getModuleText('2');
alert(selectedText);

mitchellsimoens
10 Oct 2009, 5:14 PM
I modified your code to test this and I get undefined and then the error on the return line


Application.Localdata.Arrays = function() {
var Modules = [
['1', 'One']
,['2', 'Two']
,['3', 'Three']
];

var ModuleArray;

return {
getModules: function() {
if (ModuleArray == null) {
ModuleArray = new Ext.data.ArrayStore({
fields: ['id', 'module']
,data: Modules
})
}
return ModuleArray;
}
,getModuleText: function(id){
// alert(id);
alert(ModuleArray.getById('2'));
return ModuleArray.getById(id).get('module'); // ModuleArray exists but method getById fails!
}
}
}();

Chris55
13 Oct 2009, 9:01 PM
The ArrayStore method getById(String) does not function correctly then as ModuleArray is defined with content. Is this method a known issue or a new bug. Thanks.


I modified your code to test this and I get undefined and then the error on the return line


Application.Localdata.Arrays = function() {
var Modules = [
['1', 'One']
,['2', 'Two']
,['3', 'Three']
];

var ModuleArray;

return {
getModules: function() {
if (ModuleArray == null) {
ModuleArray = new Ext.data.ArrayStore({
fields: ['id', 'module']
,data: Modules
})
}
return ModuleArray;
}
,getModuleText: function(id){
// alert(id);
alert(ModuleArray.getById('2'));
return ModuleArray.getById(id).get('module'); // ModuleArray exists but method getById fails!
}
}
}();

Chris55
14 Oct 2009, 7:26 AM
Is the core team aware of this potential bug?

Condor
14 Oct 2009, 7:40 AM
You mean this bug (http://www.extjs.com/forum/showthread.php?t=71521)?

Chris55
14 Oct 2009, 7:59 AM
Great! I am just trying to contribute, however minor it may be, via usage and feedback. Will the method fix be available in 3.1? Thanks.