Hybrid View
-
16 Oct 2012 11:58 PM #1
Cannot Load Store Data in Browser
Cannot Load Store Data in Browser
Hello everybody,
Now I using Sencha Architect 2 and my problem is cannot load data in List. The JSON data return from WCF service and I used Ajax Proxy to get JSON data and used JSON reader, it can show in IDE but cannot show in browser. So I searched the solution in this forum, I found they suggest to use JSONP Store so I tried JSONP Store, JSONP Proxy and JSON Reader but it even cannot load data in IDE
This is my store:
Ext.define('MyApp.store.MyStore1', {extend: 'Ext.data.Store',
requires: ['MyApp.model.mPerson'],
config: {model: 'MyApp.model.mPerson',storeId: 'MyStore1',proxy: {type: 'ajax',url: 'http://localhost:3535/Service1.svc/Person',reader: {type: 'json',rootProperty: 'GetResultsResult'}}}});Please help me .....
-
17 Oct 2012 7:53 AM #2
If you are trying to do cross domain requests, yes you will want to use Json-P. Are you wrapping your JSON in a callback on the server?
http://en.wikipedia.org/wiki/JSONP
Moving to help...Aaron Conran
@aconran
Sencha Architect Development Team
-
17 Oct 2012 9:00 PM #3
Hi,
This is my code:
Ext.define('MyApp.store.MyStore1', {extend: 'Ext.data.Store',
requires: ['MyApp.model.mPerson'],
config: {model: 'MyApp.model.mPerson',storeId: 'MyStore1',proxy: {type: 'jsonp',url: 'http://localhost:3535/Service1.svc/Person',reader: {type: 'json',rootProperty: 'GetResultsResult'}}}});When I tried to load data, I got this error
SyntaxError: Parse error
Source Class: http://localhost:3535/Service1.svc/P...sonP.callback2 Line 1
The json data is :
{"GetResultsResult":[{"Age":35,"FirstName":"Peyton","LastName":"Manning"},{"Age":31,"FirstName":"Drew","LastName":"Brees"},{"Age":29,"FirstName":"Tony","LastName":"Romo"}]}Please help me, I m very new for Sencha ArchitectThank you,Su Mon
-
18 Oct 2012 5:24 AM #4
You need to wrap you json return inside the callback parameter sent by jsonp proxy in the server side code.
For example (php):
PHP Code:<?php include("connect.php");
$callback = $_REQUEST['callback'];
$query = mysql_query("SELECT * FROM Contacts") or die(mysql_error());
$rows = array('contacts' => array());
while($contact = mysql_fetch_assoc($query)) { $rows['contacts'][] = $contact; }
header('Content-Type: text/javascript');
echo $callback . '(' . json_encode($rows) . ');';?>Last edited by loiane; 18 Oct 2012 at 5:25 AM. Reason: fixed code
Sencha/Java evangelist
Author of ExtJS 4 First Look and Mastering Ext JS books
English blog: http://loianegroner.com
Portuguese blog: http://loiane.com
Sencha Examples: https://github.com/loiane
-
12 Nov 2012 7:19 PM #5
I want to populate a form with data from a store . I see the eye beside the store , but if I do in the initialize event something like this
I get 0 records .Code:var custStore=Ext.getStore('stTest'); custStore.load(); alert(custStore.getCount());
please I do not know what I am doing wrong . an example could be great
my model and store are :
Code:Ext.define('MyApp.model.mdtest', { extend: 'Ext.data.Model', config: { fields: [ { name: 'numberField', type: 'int' }, { name: 'txtField', type: 'string' } ], proxy: { type: 'ajax', url: 'Data/mdtest.json', reader: { type: 'json', rootProperty: 'test' } } } }); Ext.define('MyApp.store.stTest', { extend: 'Ext.data.Store', requires: [ 'MyApp.model.mdtest' ], config: { autoLoad: true, model: 'MyApp.model.mdtest', storeId: 'stTest' } });Last edited by aconran; 13 Nov 2012 at 5:51 AM. Reason: add code tags
-
13 Nov 2012 5:54 AM #6
Stores are loaded asynchronously. When you execute the load method it is going to begin the load request, it won't be until a few seconds later that the request will return with the results.
Both the Touch and Ext first application examples illustrate loading data into stores and binding to a visual widget.
http://docs.sencha.com/architect/2/#...st_desktop_app
http://docs.sencha.com/architect/2/#...rst_mobile_appAaron Conran
@aconran
Sencha Architect Development Team


Reply With Quote