PDA

View Full Version : Store class does not see URL config



CSchmitz81
10 Feb 2013, 5:20 PM
Hi,

I'm creating a website and I want to be able to read and write to and from a mysql database. I've built up my site and tested the store/model/gridpanel with inline data in the store to confirm it works.

I then built a php file to access my database and return the matching data in json format. I've tested the php page out (by directly accessing it in the browser) and it does return the data correctly.

The problem I'm running into is my store/proxy setup. When I fire up my site I and try to access the store, I get:


Uncaught Ext.data.proxy.Server.buildUrl(): You are using a ServerProxy but have not supplied it with a url.

My store contains a url. The store looks like this:



Ext.define('CaRWedding.store.EventList',{
extend : 'Ext.data.Store',
requires : ['Ext.data.reader.Json','Ext.data.writer.Json'],


config:{
model: 'CaRWedding.model.EventList',


proxy:{
type : 'ajax',
url : 'resources/php/weddingdb.php',
reader : 'json'
}


}
});


The url is definitely pointing to the right file (appending it to the end of the site's url returns the desired list(I'll be enabling the .htaccess file later so you can nav to the file, btw)), but I still get that error.

Any tips??

Thanks

StuartAshworth
10 Feb 2013, 7:03 PM
If you remove the configuration from the "config" object it should work.

I threw it into a sample project of mine and doing that made it work - although I was seeing different error messages to you.

Hope this helps!

Stuart

sword-it
10 Feb 2013, 10:16 PM
Hi CSchmitz89,

Try the following code-



Ext.define('CaRWedding.store.EventList',{
extend : 'Ext.data.Store',
requires : ['Ext.data.reader.Json','Ext.data.writer.Json'],
model: 'CaRWedding.model.EventList',
proxy:{
type : 'ajax',
url : 'resources/php/weddingdb.php',
reader : 'json'
}
});

CSchmitz81
11 Feb 2013, 5:53 AM
Thanks Stoot98 and sword-it for your replies. That took care of the issue. I'm now getting a response back from my php and I can run with it from there.


It does raise another question for me though, how do you determine when there should be and should not be a config object in your class definition?


I had assumed up until now that any any item in the documentation listed under the 'Configs' section of the documentation needs to be enclosed within a config object in your class definition.


How can you tell when something should be within a config object and when it shouldn't?

sword-it
11 Feb 2013, 6:19 AM
I had assumed up until now that any any item in the documentation listed under the 'Configs' section of the documentation needs to be enclosed within a config object in your class definition.


CSchmitz89,

All config options of the relative class should be put direct (not under in config). As you seen in Store class there is no config option.