PDA

View Full Version : pagingmemoryproxy



azami1986
12 Mar 2010, 1:32 AM
Hi there,

I have a Problem with the pagingmemoryproxy. I tried to receive a json file from the server. I want to load a json file in a grid. That look as follows:


store : new Ext.data.Store({
remoteSort: true,
proxy: new Ext.ux.data.PagingMemoryProxy(new Ext.data.HttpProxy({url: 'http://localhost:8080/test/jsp/js/extjs/ext-3.1.1/examples/experiments/protocolmask/products.json'})),
listeners : {
loadexception : console.log
},
reader: new Ext.data.JsonReader({
root : "rows",
totalProperty : 'totalCount',
listeners : {
loadexception : console.log
},
fields : [{
name : 'name'
}, {
name : 'id'
}, {
name : 'status'
}, {
name : 'user'
}, {
name : 'startdate',
type : 'date',
dateFormat : 'n/j h:ia'
}, {
name : 'enddate',
type : 'date',
dateFormat : 'n/j h:ia'
}, {
name : 'desc'
}, {
name : 'imageLink'
}, {
name : 'error'
}]
})
}),I load the store at the latest possible moment


this.on({
afterlayout : {
scope : this,
single : true,
fn : function() {
this.store.load({
params : {
start : 0,
limit : 10
}
});
}
}
});But always I get this error message:
Object { api=Object, more...} Object { params=Object} null TypeError: root is undefined { message="root is undefined", more...}

What am I doing wrong?

Best regards
Azami

fay
12 Mar 2010, 3:11 AM
1. Maybe I'm wrong, but where have you seen an example of PagingMemoryProxy that takes a HttpProxy in it's constructor? PagingMemoryProxy expects "data".

2. Does products.json have a "root" called "rows"? Post a sample of your json file.


To isolate the problem make sure you first can load your json file without the use of PagingMemoryProxy.

azami1986
12 Mar 2010, 3:53 AM
Thanks for the Answer. The json file looks as following.


{
"totalCount" : 15,
"rows" : [{
"name" : "God of War 3",
"id": "1",
"status" : "successful",
"user" : "Administrator",
"startdate" : "7\/1 11:00am",
"enddate" : "8\/1 12:00am",
"imageLink": "http://playstation3.gaming-universe.de/screens/boxart_us_god-of-war-3.jpg",
"desc" : "God of War is a video game for the PlayStation 2 console released on March 22, 2005. It is an action-adventure game based on Greek mythology. God of War was developed by Sony Computer Entertainment's Santa Monica division. It is the first installment of the God of War series of games and the second chronologically.",
"error" : ""
}
}

How can I change my code, to receive a data. I want to get the data from a lokal webserver (tomcat) ?

fay
12 Mar 2010, 4:06 AM
Take a look at the JsonStore (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.JsonStore) documentation. For example:


Ext.onReady(function(){
var store = new Ext.data.JsonStore({
url : '/my-path/products.json',
root : 'rows',
totalProperty : 'totalCount',
fields : [
{name : 'name'}, {name : 'id'}, {name : 'status'}, {name : 'user'},
{name : 'startdate', type : 'date', dateFormat : 'n/j h:ia'},
{name : 'enddate', type : 'date', dateFormat : 'n/j h:ia'},
{name : 'desc'}, {name : 'imageLink'}, {name : 'error'}
],
listeners : {
load: function()
{
},
exception: function()
{
}
}
});

store.load();
});