Вопрос

I'm trying to create a search form view based on the following example of Sencha : http://try.sencha.com/touch/2.0.0/examples/list-search/viewer.html

I made a few changes just not to create the view by code but export it in a view.

To set up the store, i use this in the config :

store: Preconisations.app.getStoreAdherents(),

where Preconisations is my project name and getStoreAdherents the function set in the app.js:

getStoreAdherents: function () {
    if (!this.storeAdherents) {
        var gestionAdherent = new DAL_Adherent(); // custom classes 
        var tc = gestionAdherent.GetAll(); // and functions which returns a json string with data

        this.storeAdherents = Ext.create('Ext.data.Store', {
            model: "Preconisations.model.ADHERENT",
            data: tc,
            sorters: 'nom',
            groupField: 'code'
        });
    }

    return this.storeAdherents;
}

Now, everything works fine but when i make the testing or the production build, i've got this error :

Uncaught TypeError: Cannot call method 'getStoreAdherents' of undefined

at the store definition...

Maybe, there's a better way to set up the store by code but i can't understand why it's working in developpement and not with the production or testing build...

Is anyone had this problem ? Or how do you set up dynamically a store with a function ?

Thanks... I'm banging my head on the wall on this one...

Это было полезно?

Решение 2

In fact i think there's a bug in setting a store dynamically in the config. I found this workaround which work in developpement and in build production :

I don't specify a store : xxxx in the view. Instead, in a controller i put this code in the launch function :

this.getMainView().setStore(this.getStoreAdherents());

where getMainView is a reference to my view.

That's all !

Другие советы

It is clear that you have a build dependency issue in Ext Build. In the code snippet posted, there is a chance that you missed to add "Preconisations.model.ADHERENT" to a class path. If so, please add the following to your app.js

requires: ["Preconisations.model.ADHERENT"]

If the issue persist, Please do the following diagnostics : Run your app (development mode) in Google Chrome with the Console open; Look for warnings that states a particular class is being synchronously loaded and add requires statement for those classes.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top