View Full Version : Requesting complete Store/Model example

8 Jul 2010, 11:17 AM
I'd love to see a complete example of a store that loads data with json.


"Title":"Java Head",
"Contributors":"Hergesheimer, Joseph"},
"Contributors":"Rischpater, Ray",
"Title":"Beginning Java ME platform",
"Contributors":"Zukowski, John",
"Title":"Java 6 platform revealed",
"Contributors":"Wood, Jo",
"Title":"Java programming for spatial sciences",


Ext.regModel('document', {
idProperty: 'doc-id',
fields: ['doc-id', 'common-id', 'Title', 'Contributors']

var store = new Ext.data.Store({
autoLoad: true,
model: 'document',
storeId: 'mystore',
proxy: {
url: 'http://somehost.com/script',
type: 'ajax',
reader: {
type: 'json',
root: 'response.docs'
baseParams: {
wt: 'json',
raw: 'true',
fl: 'doc-id,common-id,Title,Contributors',
start: '0',
rows: '10',
q: 'Title:Java'


xhr.getAllResponseHeaders() is null

We're evaluating different platforms/frameworks for mobile development, we think Sencha will be able to do everything we want, but the docs are out of sync with the source. Just making an ajax call to pull in some json is the cornerstone of probably most apps, but I can't get this working.

I'd greatly appreciate any help or suggestions.


9 Jul 2010, 4:16 AM
Works fine for me (I can post my code later). Although I agree things in the docs are out of sync. Patience I think, is required at this point.

But in looking at your code, my quicky "while I'm sipping coffee" observation is if your URL is valid?


Perhaps you edited it. My suggestion is to use FireBUG or equivalent and see what the POST and responses are.

All that said, more examples I think are on the way.

13 Jul 2010, 11:32 AM
Yes, we are planning on having more data examples, and also new guides and docs are being written.

13 Jul 2010, 11:48 AM
I will try and throw together some examples. One thing I found out the hard way is to make sure you json is valid. I ran your json through http://www.jsonlint.com/ and there was an error. It was an easy fix

"responseHeader": {
"status": 0,
"QTime": 0,
"params": {
"raw": "true",
"fl": "doc-id,common-id,Title,Contributors",
"indent": "on",
"start": "0",
"q": "Title:Java",
"wt": "json",
"rows": "4"
"response": {
"numFound": 59,
"start": 0,
"docs": [
"doc-id": "58900",
"common-id": "/ebooks/oca1/26/javahead00herguoft",
"Title": "Java Head",
"Contributors": "Hergesheimer, Joseph"
"Contributors": "Rischpater, Ray",
"Title": "Beginning Java ME platform",
"common-id": "/ebooks/ebooks0/springer/2010-02-11/2/9781430210627",
"doc-id": "260661"
"Contributors": "Zukowski, John",
"Title": "Java 6 platform revealed",
"common-id": "/ebooks/ebooks0/springer/2009-12-01/4/9781430201878",
"doc-id": "265847"
"Contributors": "Wood, Jo",
"Title": "Java programming for spatial sciences",
"common-id": "/ebooks/ebooks0/tf/2010-04-28/1/0203166175",
"doc-id": "252882"

22 Oct 2010, 12:39 AM

i have the same problem.


{"products": [{"name": "Some Product", "price": 9.99, "image_url": "product1.jpg", "in_stock": true},{"name": "Another Product", "price": 7.50, "image_url": "product2.jpg", "in_stock": true},{"name": "A third product", "price": 2.35, "image_url": "product3.jpg", "in_stock": false}]}

JavaScript Code:

var urlJson = 'http://localhost:8080/project/ProductJSON';

Ext.regModel('Product', {
fields: [
{name: 'name', type: 'string'},
{name: 'description', type: 'string'},
{name: 'price', type: 'float'},
{name: 'image_url', type: 'string'},
{name: 'in_stock', type: 'boolean'}

var productsList = new Ext.DataView( {
store : new Ext.data.Store( {
model : 'Product',
proxy : {
type : 'ajax',
url : urlJson,
reader : {
type : 'json',
root : 'products'
tpl : new Ext.XTemplate('<tpl for=".">', '<div>',
'<img src="{name}" />', '<div class="button">Buy</div>',
'</div>', '</tpl>'),
fullscreen : true


- xhr.getAllResponseHeaders() is null
- Result of expression 'records' [undefined] is not an object. ext-touch-debug.js:5484