I've tried searching for an answer, as it is possible the guidance I need is relatively simple. I have a number of stores with associations (belongsTo, hasMany) and I'm trying to utilize data in a list from that list's store's associated data. Based on some of the results I found in searching, I've tried adding a "prepareData" function to the List which does seem to run as the list is rendered, but unclear how to get the associated data from within the prepareData function (assuming this is the right way to go.) Any help or tips would be greatly appreciated.
List view:
Code:
Ext.define('Tally.view.Games', { extend: 'Ext.List',
xtype: 'gamelist',
prepareData: function(data, idx, record)
{
data.hasRelated = "test";
data.locname = data.location.name; // I know this isn't right, but how?
return data;
},
requires: [
'Ext.dataview.List',
'Tally.store.Games'
],
config: {
title: 'Games',
itemTpl: '{label}{hasRelated}',
store: 'Games'
}
});
Game Model:
Code:
Ext.define('Tally.model.Game', {
extend: 'Ext.data.Model',
requires: [ 'Ext.data.identifier.Uuid',
'Ext.data.proxy.LocalStorage'],
config: {
identifier: 'uuid',
belongsTo: 'Team',
hasMany: 'Tevent',
belongsTo: 'Location',
hasMany: 'Series',
fields: [
{ name: 'id', type: 'string' },
{ name: 'label', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'team_id', type: 'string' },
{ name: 'location_id', type: 'string' },
{ name: 'starttime', type: 'date' },
{ name: 'closetime', type: 'date' },
{ name: 'notes', type: 'string' },
{ name: 'gamestatus', type: 'string' },
{ name: 'publicstatus', type: 'string' },
{ name: 'lastupdate', type: 'date' },
{ name: 'createddate', type: 'date' },
{ name: 'dirty', type: 'boolean' }
],
proxy: {
type: 'localstorage',
id: 'games'
}
}
});
Location Model:
Code:
Ext.define('Tally.model.Location', {
extend: 'Ext.data.Model',
requires: [ 'Ext.data.identifier.Uuid',
'Ext.data.proxy.LocalStorage'],
config: {
identifier: 'uuid',
hasMany: 'Game',
fields: [
{ name: 'id', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'phone', type: 'string' },
{ name: 'address1', type: 'string' },
{ name: 'address2', type: 'string' },
{ name: 'roomsuite', type: 'string' },
{ name: 'city', type: 'string' },
{ name: 'state', type: 'string' },
{ name: 'country', type: 'string' },
{ name: 'postalcode', type: 'string' },
{ name: 'latitude', type: 'float' },
{ name: 'longitude', type: 'float' },
{ name: 'lastupdate', type: 'date' },
{ name: 'createddate', type: 'date' },
{ name: 'dirty', type: 'boolean' }
],
proxy: {
type: 'localstorage',
id: 'locations'
}
}
});