PDA

View Full Version : I Want to create JsonReader from Ext Designer, but i have troubles



crasho
2 Apr 2010, 10:05 AM
Hi.

I'm working in a project, and i'm using ext designer. I have already the GUI, however i need load a combo with data from a database. I tried to create a Json Store, but i had troubles.

Features of the project:

- server="localhost"
- path = var/www/uimqroo/alumnos/
- main file= captura.php
- ajax file= ajax_cbo_edo_civil_alumno.php
- OS = Linux Ubuntu 9.10 64 bits
- Extjs = 3.1

After to create Json Store and push "Load Data", appear a error message from Ext Designer is "Unable to load data using supplied configuration", the code is:



storeEstadosCiviles = Ext.extend(Ext.data.JsonStore, {
constructor: function() {
storeEstadosCiviles.superclass.constructor.call(this, {
storeId: 'storeEstadosCiviles',
idProperty: 'id_edo_civil',
root: 'rows',
url: 'ajax_cbo_edo_civil_alumno',
autoLoad: true,
fields : [
{
xtype: 'datafield',
name: 'id_edo_civil',
type: 'int',
mapping: 'id_edo_civil'
},
{
xtype: 'datafield',
name: 'd_edo_civil',
type: 'string',
mapping: 'd_edo_civil'
}
]
});
}
});
new storeEstadosCiviles();
the php code of ajax file is:


header("Content-Type: text/html; charset=iso-8859-1");
header("Content-Encoding :iso-8859-1");

$path = dirname(__FILE__);
require_once("$path/../libs/adodb/adodb-exceptions.inc.php");
require_once("$path/../libs/adodb/adodb.inc.php");
require_once("$path/../includes/utf8.php") ;
require_once("$path/../includes/config.php");
require_once("$path/../includes/conexion.php");

//Conexión a la base de datos
$db=Conectar();


$qryBuscarEdosCiviles="select id_edo_civil,d_edo_civil
from dbuimqroo.uimqroo_cat_edo_civil";

$tt = $db->GetOne("SELECT COUNT(*) FROM dbuimqroo.uimqroo_cat_edo_civil");
$rs = $db->SelectLimit($qryBuscarEdosCiviles,1000,0);
$rows = $rs->GetAll();
$rs->Close();

$response = array("success" => true, "total" => $tt , "rows"=> $rows);
echo json_encode(utf8_encode_array($response));

The output file is:
{"success":true,"total":"2","rows":[{"id_edo_civil":"1","d_edo_civil":"SOLTERO"},{"id_edo_civil":"2","d_edo_civil":"CASADO"}]}


In Edit->Preferences i have this:

URL PREFIX: http://localhost
Ext Direct API:
Export Path :
Ext js Path : ../../ext3/
Spaces to indent: 3


Why the error? anybody have a example or tutorial for to do this?

Thanks a lot

aconran
2 Apr 2010, 10:51 AM
Put a / at the end of your localhost in your url prefix.

Does putting the following url in your browser return your json?
http://localhost/ajax_cbo_edo_civil_alumno

crasho
2 Apr 2010, 11:03 AM
Hi Anconran.

1.- I put a /
2.- No, i don't, mi site is in localhost/uimqroo/alumnos/ if i put localhost/uimqroo/alumnos/ajax_cbo_edo_civil_alumno (http://localhost/ajax_cbo_edo_civil_alumno).php i receive the JSON.

thanks

aconran
2 Apr 2010, 11:23 AM
Change either the prefix or the url so that it generates a url that will get the JSON.

You could use the url Prefix of "http://localhost/uimqroo/alumnos/" and your current url.

crasho
2 Apr 2010, 11:54 AM
Hi

i did this:

in URL Prefix put http://localhost/uimqroo/alumnos and on Property URL i left ajax_cbo_edo_civil_alumno.php, but, don't work, i receive the same error message. :(

aconran
2 Apr 2010, 12:04 PM
Does the url prefix have the ending /?

crasho
2 Apr 2010, 12:10 PM
Yes, it does, sorry i forgot to put it.

is: http://localhost/uimqroo/alumnos/

But, the same error

:-/

aconran
2 Apr 2010, 12:18 PM
Is the code in the first post accurate? Should there be a .php extension at the end of the store?

aconran
2 Apr 2010, 4:09 PM
We have this as open item internally to improve the workflow with data store. Show the data, etc

crasho
2 Apr 2010, 6:01 PM
Hi again

I put the code again:



storeEstadosCiviles = Ext.extend(Ext.data.JsonStore, {
constructor: function() {
storeEstadosCiviles.superclass.constructor.call(this, {
storeId: 'storeEstadosCiviles',
idProperty: 'id_edo_civil',
root: 'rows',
url: 'ajax_cbo_edo_civil_alumno.php',
autoLoad: true,
fields : [
{
xtype: 'datafield',
name: 'id_edo_civil',
type: 'int',
mapping: 'id_edo_civil'
},
{
xtype: 'datafield',
name: 'd_edo_civil',
type: 'string',
mapping: 'd_edo_civil'
}
]
});
}
});
new storeEstadosCiviles();


I did all, directly using netbeans and work the ajax, but, i want to do from ext designer.

aconran
2 Apr 2010, 6:13 PM
@crasho - Please upgrade, I've provided a little bit of additional information about where your application was trying to access when it fails as well as fix a related bug. This is in xds-1.0.0.6.

crasho
2 Apr 2010, 7:46 PM
Hi again.

well, the JSON Reader fails in design mode. The steps are:

1.- Create GUI with combos
2.- Create a JSON Store (Add Json Store)
3.- Properties:
root: rows
url : ajax_cbo_edo_civil_alumno.php
jsclass: storeEstadosCiviles
idproperty: id_edo_civil
4.- Add two fields
-id_edo_civil
name: id_edo_civil
mapping: id_edo_civil
type:int
-d_edo_civil
name: d_edo_civil
mapping: d_edo_civil
type:string


After, i put my mouse on JSON Store Name and i put right button and appear this menu
-Select
-Duplicate
-Delete
-Load data
-Quick Add

I select "Load Data", i think that this option should me the result of php File, but send me error "Unable to load data using the supplied configuration"

In Edit->Preferences i have got this:
URL PREFIX: http://localhost/uimqroo/alumnos/
EXT JS PATH: ../../ext3/

Thanks

crasho
3 Apr 2010, 5:23 AM
Hi again.

I upgrade and the error now is:

"Unable to load data using the supplied information
Open in browser: undefined"

What does it mean the message?


the error appear me, when put my mouse on Json Store, and i push right button, and select "Load Data"
thanks

aconran
3 Apr 2010, 11:15 AM
The message means that the designer is calculating the url to access as "undefined"!

Could you please paste the urlPrefix and url used in your JsonStore so that we can see if this is a configuration bug or a designer error?

crasho
3 Apr 2010, 11:41 AM
Hi.

Ok, there are here:

URL PREFIX: http://localhost/uimqroo/alumnos/
AJAX FILE: ajax_cbo_edo_civil_alumno.php

The ajax File is in folder "alumnos"
The xds file is in the same folder "alumnos"

thanks

crasho
3 Apr 2010, 11:46 AM
Hi.

URL PREFIX: http://localhost/uimqroo/alumnos/

url: ajax_cbo_edo_civil_alumno.php


AJAX FILE is in folder alumnos, and the file .xds is the same folder.

Thanks

crasho
3 Apr 2010, 2:31 PM
Hi

PREFIX URL: http://localhost/uimqroo/alumnos/
url : ajax_cbo_edo_civil_alumno.php


The xds file is in folder alumnos and ajax_cbo_edo_civil_alumno too.


thanks

aconran
3 Apr 2010, 5:41 PM
crasho - Could you send me your xds file so that I can test?

crasho
3 Apr 2010, 7:56 PM
Hi

This is the file


Thanks