PDA

View Full Version : [exapmle]How to fill form with values using Ext.data.Store (JSON)



gravic
27 May 2007, 1:23 PM
If enybody could give me a simple example of using ext,JSON + PHP (without XML) to fill form with values?

Big thanks.

VinylFox
27 May 2007, 2:00 PM
Your comment from the tutorial section...


hello, this exapmle (http://www.vinylfox.com/extjs/examples/forms-submit.zip) didn't work! also IE unrecognize method getAt(0). Without getAt(0) inputs are blank (but when I do that: employee_name.setValue("Ann") everything is all right... I don't know what is cause..

can you check to see if the JSON string has any data?

do you have a working example posted somewhere that i can look at?

gravic
27 May 2007, 11:08 PM
can you check to see if the JSON string has any data?
yes, JSON string has data.. I get strange error using method getAt(0)


do you have a working example posted somewhere that i can look at?
my example is in attachment (attachment.zip)

VinylFox
28 May 2007, 6:01 AM
Your "b.php" is not creating an array of objects to pass to json_encode

You have two options, you can simply add "[ ]" around your JSON output, or pass json_encode an array of objects.

Option 1


$arr = array();
$arr['name'] = 'a';
$arr['title'] = 'b';

echo "[".json_encode($arr)."]";



Option 2


$arr = array();
$obj->name = 'a';
$obj->title = 'b';
$arr[] = $obj;

echo json_encode($arr);


Option 2 would be my preference, since its really the appropriate way to do it, but Option 1 works just fine as well.

gravic
28 May 2007, 12:07 PM
thanks VinylFox.. after add getAt(0) everything working now :)

big thanks...