Php ExtJS/Touch-列表中显示的来自模型关联的数据
我想在SenchaTouchMVC应用程序中展示一些从php脚本列表中提取的数据。我有客户模式和预订模式。关联很简单:客户可以有许多预订,预订属于客户。 我创建了一些模型Php ExtJS/Touch-列表中显示的来自模型关联的数据,php,mysql,model-view-controller,extjs,sencha-touch,Php,Mysql,Model View Controller,Extjs,Sencha Touch,我想在SenchaTouchMVC应用程序中展示一些从php脚本列表中提取的数据。我有客户模式和预订模式。关联很简单:客户可以有许多预订,预订属于客户。 我创建了一些模型 App.models.ClientModel = Ext.regModel('ClientModel', { idProperty: 'clientID', fields: [ 'clientID', 'firstName', 'lastName', 'email', 'phone1',
App.models.ClientModel = Ext.regModel('ClientModel', {
idProperty: 'clientID',
fields: [
'clientID',
'firstName',
'lastName',
'email',
'phone1',
'extension1',
'phone2',
'extension2',
'workPh',
'workExt',
'address1',
'address2',
'city',
'province',
'country',
'reminderType',
'postal',
'noteID',
'referredBy',
'quickLogin',
'creationDate',
'modifiedDate',
'birthDate'
],
proxy: {
type: 'rest',
url : 'includes/data_api',
appendId: true,
extraParams: {
model: 'Client'
},
format: 'php',
reader: {
type: 'json',
root: 'items'
}
},
associations: [
{type: 'hasMany', model: 'BookingModel', primaryKey: 'bookingId', foreignKey: 'clientID', name: 'bookings'}
]});
App.models.BookingModel = Ext.regModel('BookingModel', {
idProperty: 'bookingID',
fields: [
'bookingID',
'clientID',
'stylistID',
'salonID',
'serviceID',
'startDate',
'splitStartDate',
'splitEndDate',
'endDate',
'status',
'clientNotes',
'stylistNotes',
'reminderSent',
'charge',
'offset'
],
proxy: {
type: 'rest',
url : 'includes/data_api',
format: 'php',
appendId: true,
extraParams: {
model: 'Booking'
},
reader: {
type: 'json',
root: 'items'
}
},
associations: [
{type: 'belongsTo', model: 'ClientModel', primaryKey: 'clientID', foreignKey: 'clientID', getterName: 'getClient', name: 'client'}
]});
经过几次战斗,我得到了hasMany关联,并将代码sampe放入控制器:
var client = App.stores.ClientStore.getAt(1);
var bookings = client.bookings();
bookings.clearFilter();
bookings.filter('clientID', client.get('clientID'));
bookings.load();
我无法让belongsTo协会工作。如果我尝试下面的代码,我会看到对php脚本的请求,但没有任何附加参数,因此它会返回完整的客户机列表,而console.log总是返回第一个
booking.getClient({
success: function(client, operation) {
console.log(client);
}
});
所以,第一个问题是:我怎样才能让它工作?
第二个问题:
我怎样才能让它在列表上工作?据我所知,我只传递了列表的配置对象中的存储。因此,如果我必须提出一些额外的请求来获取相关的数据,我如何才能在列表上这样做?如何在xtemplate中为每个列表项引用关联数据