PDA

View Full Version : Problem with setting api parameter under Config in Ajax Proxy



franck.pedrini
12 Aug 2012, 4:50 AM
Hello everyone,
I just got started with Sencha Architect 2 and for my first project I followed along the working example found at:
http://www.sencha.com/forum/showthread.php?201231-Retrieving-MySql-Queries-to-JSON-in-Architect-how
(The fourth post by d.velev has said project attached).

Now, I looked at the scripts to familiarise myself with the framework, and decided to create my own CRUD application via Architect, when I run up against the following problem;
when I create a JsonStore from the Inspector, and select the Ajax Proxy, I wish to enter the four .php files that map to the four CRUD operations, like so:


read: "data/readUser.php",
update: "data/updateUser.php",
create: "data/createUser.php",
destroy: "data/destroyUser.php"

so that part of the script would look like this:


...
proxy: {
type: 'ajax',
api: {
read: 'data/readUser.php',
update: 'data/updateUser.php',
create: 'data/createUser.php',
destroy: 'data/deleteUser.php'
},
reader: {
type: 'json',
root: 'data'
}
...

But when I open up Architect and navigate under Config, api, in the AjaxProxy of my JsonStore, all I can enter is a string of text which then automatically generates the following code:


...
proxy: {
type: 'ajax',
api: 'read: "data/readUser.php",\n update: "data/updateUser.php",\n create: "data/createUser.php",\n destroy: "data/destroyUser.php"',
reader: {
type: 'json',
root: 'data'
}
}
...

which obviously doesn't work.
I wonder what has to be entered in the 'api' field in order for Architect to generate the code I'm after.

Thanks in advance for your help,

Frank

aconran
13 Aug 2012, 9:36 AM
You need to wrap what you entered in curly braces.



{
// what you have currently
}

aconran
14 Aug 2012, 7:32 AM
You pasted in


read: "data/readUser.php",
update: "data/updateUser.php",
create: "data/createUser.php",
destroy: "data/destroyUser.php"


For the api config, you should have pasted in


{
read: "data/readUser.php",
update: "data/updateUser.php",
create: "data/createUser.php",
destroy: "data/destroyUser.php"
}

franck.pedrini
14 Aug 2012, 8:13 AM
Sorted, thanks.
Should I feel ashamed it was that simple? eheh