PDA

View Full Version : error: Uncaught TypeError: Cannot call method 'substring' of undefined



soumeya
16 Aug 2013, 12:53 AM
Bonjour,
I work with desktop sencha extjs and i wanted create a combobox into window but an error occured :

Uncaught TypeError: Cannot call method 'substring' of undefined

Here is the code:

var myStore = Ext.create('Ext.data.Store', {
fields: ['text'],
storeId: 'myStore',
data: [
{text: 'Red'},
{text: 'Yellow'},
{text: 'Green'}
]
});

var combo = Ext.create('Ext.form.field.ComboBox', {
store: 'myStore'
});


var win = desktop.getWindow('events');
if(!win){
win = desktop.createWindow({
id: 'events',
title:'Events',
width:740,
height:480,
iconCls: 'events',
animCollapse:false,
constrainHeader:true,
layout: 'fit',
items: [combo]


});
}
win.show();
return win;

who can help me? thanks.

Gary Schlosberg
19 Aug 2013, 2:37 PM
Seems like you are not getting your data from the store. Here's an example from the docs that does what you are trying to do:


// The data store containing the list of states
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
//...
]
});

// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});