In this tutorial you will learn how to use the hasMany association, a feature of Sencha Touch models that allows you to connect two models in a one-to-many relationship. The model configs you will learn about in this post are the following:
- hasMany
- belongsTo
The back-end code for this tutorial is in C#. I also published a version of this Sencha Touch tutorial using PHP.
Let’s create a simple Sencha Touch application with the following files:

In the model/Hotel.js file, you will define a Hotel model like so:
Ext.define('App.model.Hotel', {
extend: 'Ext.data.Model',
config: {
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' },
{ name: 'address', type: 'string' },
{ name: 'status', type: 'int' }
],
hasMany: {
model: 'App.model.Room',
name:'rooms'
}
}
});






