Results 1 to 4 of 4

Thread: pagingmemoryproxy

  1. #1

    Default pagingmemoryproxy

    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:

    Code:
    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

    Code:
    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

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    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.

  3. #3

    Default

    Thanks for the Answer. The json file looks as following.

    Code:
    {
        "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) ?

  4. #4
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    Take a look at the JsonStore documentation. For example:

    Code:
    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();
    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •