0
votes

I'm attempting to populate a grid with a data store that uses a proxy and a defined model and reader. Similar stores aren't having the same issue, but one is.

Model

Ext.define('DrillDescriptionGridModel', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'sentTime',        type: 'string'},
        {name: 'sDescription',    type: 'string'},
        {name: 'receivedTime',    type: 'string'},
        {name: 'seconds',        type: 'number'},
        {name: 'formatted',        type: 'string'},
        {name: 'alertPhone',    type: 'string'},
        {name: 'alertEmail',    type: 'string'}
    ]
});

Reader

var DrillDescriptionReader = Ext.create('Ext.data.JsonReader', {
    type:    'json',
    model:    'DrillDescriptionGridModel',
    root:    'data'
});

Store

DrillDescriptionStore = Ext.create('Ext.data.Store', {
    model: 'DrillDescriptionGridModel',
    autoLoad: false,
    proxy: {
        type:             'ajax',
        url:            '/inc/ajax/Monitors.php',
        actionMethods:    'POST',
        reader:            DrillDescriptionReader
    },
    listeners: {
        load: function() {
            console.log(this.getAt(0));
            DrillDescriptionPanel.show();
        }
    }
});

The proxy returns a json string

{"data":[{"sDescription":"Status Normal","sentTime":"12:00:00 am","receivedTime":"12:00:01 am","seconds":"2","formatted":"2 seconds","alertPhone":"","alertEmail":""}, [...]

The console.log in the load listener displays

Ext.Class.c.m
  data: Object
    alertEmail: ""
    alertPhone: ""
    formatted: "2 seconds"
    receivedTime: "12:00:01 am"
    seconds: 2
    sentTime: "12:00:00 am"
    __proto__: Object
  [...]
  raw: Object
    alertEmail: ""
    alertPhone: ""
    formatted: "2 seconds"
    receivedTime: "12:00:01 am"
    sDescription: "Status Normal"
    seconds: 2
    sentTime: "12:00:00 am"
    __proto__: Object
[...]

Anyone know why the sDescription field would be mapped in the raw object, but not the data object, or spot an error in the code? Any help would be greatly appreciated. Thanks.

2
I've tested your code with Ext 4.0.2a in Chromium on Linux and can see sDescription in the data object too. Which version of ExtJS are you using?rocky3000
I'm using 4.0.2 (not a), tested in Chrome and FF6.0.2 on Mac, and IE8 in Windows environment with the same result.SerEnder
Your code works for me as expected with 4.0.2 too - in Chromium on Linux and Windows. Now I've no idea what could cause your problem.rocky3000

2 Answers

0
votes

if you are using extjs 4 as you tagged it .. then the json reader is not defined properly The class should be Ext.data.reader.Json

0
votes

So I've figured this one out, and unfortunately it had NOTHING to do with the code that I posted. Thanks for all the help Rocky.

I had another store a little further down in the code that was trying to utilize the same reader... which seems like it shouldn't have been a problem at all, but apparently was. Modified the reader in the store below and code worked right away.

Thanks again for the help Rocky, and thanks for taking a look nscrob.