withanx
23 Dec 2010, 12:21 PM
Anyone know what I could be doing wrong? The selected item is incorrect when I log it to the console. It appears correct visually, but it returns the wrong record.
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady : function() {
Ext.regModel('Location', {
fields: ['name', 'state_name']
});
var locationListBase = {
listeners: {
itemtap: function(list, subIdx, el, e){
var selected = list.getSelectedRecords();
console.info(selected) // Returns the wrong record, not the actually selected one
}
},
itemTpl: '<div class="contact2"><strong>{name}</strong></div>',
grouped: true,
store: new Ext.data.Store({
model: 'Location',
sorters: 'name',
getGroupString: function(record) {
return record.get('state_name');
},
proxy: {
type: 'ajax',
url : '/locations.json',
reader: {
type: 'json'
}
},
autoLoad: true
})
};
var location_list = new Ext.List(locationListBase);
var p = new Ext.Panel({
fullscreen: true,
dockedItems: [
{
dock : 'top',
xtype: 'toolbar',
title: 'App Title'
},
],
layout: 'card',
items: [location_list,{
html: 'Card 2'
}]
});
p.setActiveItem(0);
X = p
}
});
The JSON data returned looks like this:
[{"name":"Birmingham, MI","state_name":"Michigan"},{"name":"Cincinnati, OH","state_name":"Ohio"},{"name":"Farmington Hills/Farmington","state_name":"Michigan"},{"name":"Royal Oak, MI","state_name":"Michigan"},{"name":"Waterford, MI","state_name":"Michigan"},{"name":"West Bloomfield, MI","state_name":"Michigan"}]
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady : function() {
Ext.regModel('Location', {
fields: ['name', 'state_name']
});
var locationListBase = {
listeners: {
itemtap: function(list, subIdx, el, e){
var selected = list.getSelectedRecords();
console.info(selected) // Returns the wrong record, not the actually selected one
}
},
itemTpl: '<div class="contact2"><strong>{name}</strong></div>',
grouped: true,
store: new Ext.data.Store({
model: 'Location',
sorters: 'name',
getGroupString: function(record) {
return record.get('state_name');
},
proxy: {
type: 'ajax',
url : '/locations.json',
reader: {
type: 'json'
}
},
autoLoad: true
})
};
var location_list = new Ext.List(locationListBase);
var p = new Ext.Panel({
fullscreen: true,
dockedItems: [
{
dock : 'top',
xtype: 'toolbar',
title: 'App Title'
},
],
layout: 'card',
items: [location_list,{
html: 'Card 2'
}]
});
p.setActiveItem(0);
X = p
}
});
The JSON data returned looks like this:
[{"name":"Birmingham, MI","state_name":"Michigan"},{"name":"Cincinnati, OH","state_name":"Ohio"},{"name":"Farmington Hills/Farmington","state_name":"Michigan"},{"name":"Royal Oak, MI","state_name":"Michigan"},{"name":"Waterford, MI","state_name":"Michigan"},{"name":"West Bloomfield, MI","state_name":"Michigan"}]