---
title: "Sencha Touch - Extending Store - constructor call"  
description: "Sencha Touch - Extending Store - constructor call"  
author: "Anonymous User"  
published: 2013-05-31  
updated: 2013-06-01  
canonical: https://www.mindstick.com/forum/951/sencha-touch-extending-store-constructor-call  
category: "sencha touch"  
tags: ["sencha touch"]  
reading_time: 2 minutes  

---

# Sencha Touch - Extending Store - constructor call

Hi Everyone!\
I'm playing around with sencha and created a list with a store and a model:\
main:\
Ext.Loader.setConfig({enabled: true});\
Ext.application({ viewport: { autoMaximize: false}, name: 'Sencha', launch: [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server)() { Ext.create('Ext.List', { fullscreen: true, store: Ext.create('store.Test', { }), itemTpl: '{lastName}, {[firstName](https://www.mindstick.com/interview/33973/how-to-split-the-full-name-into-firstname-and-lastname-in-sql-server)} Age: {age}' });} });\
store:\
Ext.define('store.Test', {extend: 'Ext.data.Store',\
model: 'model.User',data: [ { firstName: 'Ed', lastName: 'Spencer', age: 30 }, { firstName: 'Tommy', lastName: 'Maintz', age: 41 }, { firstName: 'Aaron', lastName: 'Conran', age: 24 }, { firstName: 'Jamie', lastName: 'Avins', age: 76 }]});model:\
Ext.define('model.User', {extend: 'Ext.data.Model',fields: [ { name: 'firstName', type: '[string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp)' }, { name: 'lastName', type: 'string' }]});To this point everything [works fine](https://answers.mindstick.com/qa/115732/my-software-works-fine-on-windows-10-but-crashes-on-windows-11-why).\
Then I created a second store, which has another field 'age'. What I want now is to pass a [parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) 'model' to the store to be able to "[switch](https://www.mindstick.com/blog/104495/switch-bringing-new-advancements-in-the-education-management-system)" between different \
models. I tried something like this:\
store:\
Ext.define('store.Test', {extend: 'Ext.data.Store',myModel: null,\
constructor : function(model) { myModel = model;}, \
model: this.myModel,\
data: [ { firstName: 'Ed', lastName: 'Spencer', age: 30 }, { firstName: 'Tommy', lastName: 'Maintz', age: 41 }, { firstName: 'Aaron', lastName: 'Conran', age: 24 }, { firstName: 'Jamie', lastName: 'Avins', age: 76 }]});and in the main file:\
[...] store: Ext.create('store.Test', { model: 'model.UserWithAge' }),[...]But [Google](https://www.mindstick.com/articles/43833/google-lighthouse-and-how-is-it-changing-the-way-we-development-and-design-websites) [Chrome](https://www.mindstick.com/blog/303260/discover-google-s-latest-ip-protection-privacy-test-feature-in-chrome) gives me:\
Uncaught [TypeError](https://www.mindstick.com/forum/157755/calling-a-class-member-function-gives-typeerror-in-python-why): Object [object Object],[object Object],[object Object],[object Object] has no method 'getRange'Any hints what I've done wrong?\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Ben!\
Never mind, it was a lot easier then I thought. Instead of messing with constructors or something like that it is enough to just pass the model when creating the store as I all ready did:\
**main:**\

```
[...]    store: Ext.create('store.Test', {       model: 'model.UserWithAge'    }),[...]
```

**store:**\

```
Ext.define('store.Test', {extend: 'Ext.data.Store',model: 'model.User', //only set in case that model is not passed when createddata: [    { firstName: 'Ed',    lastName: 'Spencer', age: 30 },    { firstName: 'Tommy', lastName: 'Maintz', age: 41 },    { firstName: 'Aaron', lastName: 'Conran', age: 24 },    { firstName: 'Jamie', lastName: 'Avins', age: 76 }]});
```

\
I hope, it resolve your problem.


---

Original Source: https://www.mindstick.com/forum/951/sencha-touch-extending-store-constructor-call

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
