PDA

View Full Version : How to pass parameter/model between xmlStore?



Kitdo
15 Oct 2012, 10:57 PM
I got two xmlStore.
1. The first store(A) contain two model:
-BusID
-BusName

2. The second store(B) contain two model as well:
-routeID
-routeName

My question: How to pass BusID to routeID? Because i need to get busID as a url parameter.
If busID =1,,routeID will equals to 1 as well and display the data.

How to achieve this? Thanks much :)

mitchellsimoens
22 Oct 2012, 7:46 AM
Sounds like you want to use associations really. Without it all you have to do is resolve the other store and get the param you need

Kitdo
23 Oct 2012, 8:35 PM
These are my code:

Ext.define('MyApp.model.GetBusRoute', {
extend: 'Ext.data.Model',


uses: [
'MyApp.model.GetBusStop'
],


config: {
fields: [
{
name: 'BusRouteID'
},
{
name: 'BusRouteName'
}
],
hasMany: {
foreignStore: 'GetBusStop',
model: 'MyApp.model.GetBusStop',
primaryKey: 'BusStopID',
foreignKey: 'BusRouteID'
}
}
});

Ext.define('MyApp.model.GetBusStop', {
extend: 'Ext.data.Model',


uses: [
'MyApp.model.GetBusRoute'
],


config: {
fields: [
{
name: 'BusStopRouteID'
},
{
name: 'BusStopID'
},
{
name: 'BusStopName'
}
],
belongsTo: {
foreignStore: 'GetBusRouteStore',
associationKey: 'BusRouteID',
model: 'MyApp.model.GetBusRoute',
primaryKey: 'BusStopID',
foreignKey: 'BusRouteID'
}
}
});

How to link up both of them and retrieve the value BusRouteID... Thank you so much!