I'm having some trouble assigning a store to a list. I can do it dynamically in the controller, but I can not seem to get the store property of the list itself to work.
Controller:
Code:
Ext.define('Test.controller.PatientController', {
extend: 'Ext.app.Controller',
config: {
profile: Ext.os.deviceType.toLowerCase()
},
views: [
'PatientList'
],
stores: [
'PatientStore'
],
models: [
'PatientModel'
],
init: function()
{
Ext.getCmp('patientList').setStore('PatientStore');
}
});
Store:
Code:
Ext.define('Test.store.PatientStore', {
extend: 'Ext.data.Store',
model: 'Test.model.PatientModel',
requires: [ 'Test.model.PatientModel' ],
storeId: 'patientStore',
sorters: 'lastName',
getGroupString: function(record){
return record.get('lastName')[0];
},
autoLoad: false,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: '../Services/PatientWebService.asmx/GetAllPatients'
},
reader: {
type: 'xml',
record: 'PatientData',
root: 'ArrayOfPatientData'
},
afterRequest: function(response, opts){
}
}
});
List:
Code:
Ext.define('Test.view.PatientList', {
extend: 'Ext.dataview.List',
xtype: 'patientList',
id: 'patientList',
fullscreen: true,
config: {
itemTpl: '<div id="{id}">{lastName}, {firstName}</div>',
listeners: {
scope: this,
itemtap: this.onItemTap
}
},
onItemTap: function(record, newItem){
if(newItem.attributes['id'] != undefined)
{
Ext.getCmp('mainPanel').setActiveItem(2);
Ext.data.StoreManager.lookup('PatientDateStore').getProxy().extraParams.ID = newItem.attributes['id'].value;
Ext.data.StoreManager.lookup('PatientDateStore').load();
}
else if (newItem.childNodes[0].attributes['id'] != undefined)
{
Ext.getCmp('mainPanel').setActiveItem(2);
Ext.data.StoreManager.lookup('PatientDateStore').getProxy().extraParams.ID = newItem.childNodes[0].attributes['id'].value;
Ext.data.StoreManager.lookup('PatientDateStore').load();
}
else
{
Ext.Msg.alert('Error', 'Patient does not have a valid ID, please try again.')
}
}
});
If I put the storeId in the List's config section the data doesn't load, the only way I've seen data load is by setting it in the controller which I don't really like how that looks.
What I add to the List config section:
Code:
store: 'PatientStore'