PDA

View Full Version : JsonReader loading JSON but not populating



Ohkabaka
13 Jul 2009, 2:12 PM
so... I've been learning ExtJS on the fly during implementation of a new app... I'm fairly confident it was up to the task. Any time I have trouble, the docs, examples and forums have delivered...

The trial by fire has hit a snag... which I expect is something I missed and can't seem to find...

I even upgraded to 3, just to see if it would help (the update DID fix a different problem, so woo! and thanks)...

javascript:


iReader = new Ext.data.JsonReader(
{
root: 'rows',
id: 6
}, [
{ mapping: 0, name: 'claimedBy' },
{ mapping: 1, name: 'claimedTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s.u' },
{ mapping: 2, name: 'closedTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s.u' },
{ mapping: 3, name: 'reopenClosedTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s.u' },
{ mapping: 4, name: 'description' },
{ mapping: 5, name: 'descriptionReopenClose' },
{ mapping: 6, name: 'requestID' },
{ mapping: 7, name: 'client' },
{ mapping: 8, name: 'ReopenCount' },
{ mapping: 9, name: 'ReopenClosedBy' },
{ mapping: 10, name: 'status' },
{ mapping: 11, name: 'statusTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s.u' },
{ mapping: 12, name: 'statusBy' },
{ mapping: 13, name: 'submitBy' },
{ mapping: 14, name: 'submitTimestamp', type: 'date', dateFormat: 'Y-m-d H:i:s.u' },
{ mapping: 15, name: 'team' }
]
);

iProxy = new Ext.data.HttpProxy({
url: 'qry_data.cfm',
method: 'GET',
disableCaching: false
});

localData = {
qid: 'Q55927E27EE6927E27E27E27E27E27E27E27E49B',
queryText: 'Search Results For: Claimed Open Tickets Assigned to ohkabaka',
sortText: 'Sorted By:\nID REQUEST (DESC)\n',
success: true,
results: 11,
rows: [
[ 'ohkabaka','2009-06-17 16:04:13.91','','','Some notes','','42891','Client1','0','','','','','dummyName','2009-04-21 07:37:24.0','Warranties' ],
[ 'ohkabaka','2009-06-22 09:25:31.85','','','Some notes','','42890','Client1','0','','','','','dummyName','2009-04-21 07:33:17.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 09:25:36.943','','','Some notes','','42889','Client2','0','','','','','dummyName','2009-04-21 07:24:17.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-19 10:08:55.43','','','Some notes','','42888','Client3','0','','','','','dummyName','2009-04-21 07:23:06.0','Post-Shipment' ],
[ 'ohkabaka','2009-06-22 09:25:38.023','','','Some notes','','42887','Client4','0','','','','','dummyName','2009-04-21 07:14:07.0','Admins' ],
[ 'ohkabaka','2009-06-22 09:25:40.25','','','Some notes','','42886','Client2','0','','','','','dummyName','2009-04-21 06:57:33.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-19 10:09:41.287','','','Some notes','','42884','Client3','0','','','','','dummyName','2009-04-21 06:50:41.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 10:19:12.703','','','Some notes','','42872','Client4','0','','','','','dummyName','2009-04-20 14:44:29.0','Admins' ],
[ 'ohkabaka','2009-06-19 18:21:25.333','','','Some notes','','42871','Client3','0','','','','','dummyName','2009-04-20 14:44:13.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 10:14:55.94','','','Some notes','','42870','Client4','0','','','','','dummyName','2009-04-20 14:40:48.0','Admins' ],
[ 'ohkabaka','2009-06-29 14:46:31.11','','','Some notes','','13929','Client5','0','','','','','dummyName','2008-08-01 09:37:51.0','ARFs' ]
]
}

localStore = new Ext.data.GroupingStore({
reader: iReader,
data: localData
});

ajaxStore = new Ext.data.GroupingStore({
reader: iReader,
proxy: iProxy,
autoLoad: true,
baseParams: {iclaimed: 1, iloginname: 'ohkabaka', action: 'getRequests'}
});
The return from the get is the same as the value of localData:


{
qid: 'Q55927E27EE6927E27E27E27E27E27E27E27E49B',
queryText: 'Search Results For: Claimed Open Tickets Assigned to ohkabaka',
sortText: 'Sorted By:\nID REQUEST (DESC)\n',
success: true,
results: 11,
rows: [
[ 'ohkabaka','2009-06-17 16:04:13.91','','','Some notes','','42891','Client1','0','','','','','dummyName','2009-04-21 07:37:24.0','Warranties' ],
[ 'ohkabaka','2009-06-22 09:25:31.85','','','Some notes','','42890','Client1','0','','','','','dummyName','2009-04-21 07:33:17.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 09:25:36.943','','','Some notes','','42889','Client2','0','','','','','dummyName','2009-04-21 07:24:17.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-19 10:08:55.43','','','Some notes','','42888','Client3','0','','','','','dummyName','2009-04-21 07:23:06.0','Post-Shipment' ],
[ 'ohkabaka','2009-06-22 09:25:38.023','','','Some notes','','42887','Client4','0','','','','','dummyName','2009-04-21 07:14:07.0','Admins' ],
[ 'ohkabaka','2009-06-22 09:25:40.25','','','Some notes','','42886','Client2','0','','','','','dummyName','2009-04-21 06:57:33.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-19 10:09:41.287','','','Some notes','','42884','Client3','0','','','','','dummyName','2009-04-21 06:50:41.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 10:19:12.703','','','Some notes','','42872','Client4','0','','','','','dummyName','2009-04-20 14:44:29.0','Admins' ],
[ 'ohkabaka','2009-06-19 18:21:25.333','','','Some notes','','42871','Client3','0','','','','','dummyName','2009-04-20 14:44:13.0','Order to Invoice' ],
[ 'ohkabaka','2009-06-22 10:14:55.94','','','Some notes','','42870','Client4','0','','','','','dummyName','2009-04-20 14:40:48.0','Admins' ],
[ 'ohkabaka','2009-06-29 14:46:31.11','','','Some notes','','13929','Client5','0','','','','','dummyName','2008-08-01 09:37:51.0','ARFs' ]
]
}

localStore gives the expected result: localStore.data.items has records

ajaxStore loads the json variable into jsonData, but ajaxStore.data.items remains empty.

What am I missing?

I've been wrestling with this display for a few solid days, and I've gotten everything else working... but this, even after I've distilled it down to just these few lines of code, has driven me crazy enough to risk Animal's wrath and throw myself on the mercy of the community.

DarkStarDS
14 Jul 2009, 12:48 AM
Hey,

I am a similar problem.


ShortReportDataStore = new Ext.data.Store({
id: 'ShortReportDataStore',
proxy: new Ext.data.HttpProxy({
url: 'database.php',
method: 'POST'
disableCaching: false
}),
baseParams:{task: "LISTING_LR"}, // this parameter is passed for any HTTP request
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'VendorID', type: 'string', mapping: 'vendorID'},
{name: 'Name', type: 'string', mapping: 'name'},
{name: 'Last Login', type: 'date', mapping: 'lastlogin'},
{name: 'Login Level', type: 'number', mapping: 'loginlevel'},
{name: 'Notification Date', type: 'date', mapping: 'notifdate'},
{name: 'Time Limit', type: 'string', mapping: 'timelimit'},

]),
sortInfo:{field: 'VendorID', direction: "ASC"}
});

I actually have the data well converted in the JSON format but then Firebug tells me I have an error :
Components is not defined
chrome://firebug/content/blank.gifExt.data.JsonReader=function(A,B){A=A||{...{success:D,records:P,totalRecords:I}}});

The mapping in my database, ColumnModel and DataStore should be ok so I have no idea. Loading is working, but no display in my grid. Thank you.

DarkStarDS
14 Jul 2009, 1:34 AM
Ok, I have found the problem. I put a mistake when I declare my JsonReader :


{name: 'Login Level', type: 'number', mapping: 'loginlevel'},

This is int, not number. I lost 5 hours for that mistake. :((

tomcheng76
14 Jul 2009, 1:44 AM
it is quite difficult to find the available type.
Actually it is in the Ext.data.Field
http://extjs.com/deploy/dev/docs/source/DataField.html#cfg-Ext.data.Field-type

Ohkabaka
14 Jul 2009, 8:30 AM
Thanks for the idea, I was hopeful about that one, but no joy.

I was only typing my date fields, so I thought that might be it... I removed the typing from everything, no change.

This should not be this difficult to identify.

tryanDLS
14 Jul 2009, 9:06 AM
If you can't debug it by stepping thru the code, strip it down to 1 record/field and see if it works. Then start adding things back til you find what breaks it.

DarkStarDS
14 Jul 2009, 9:49 AM
According to the link that tomcheng76 gave, try to put in the typing the keyword "auto", then you have more chance not to be mistaken... Good luck!

Ohkabaka
14 Jul 2009, 11:47 AM
Argh.

Modified tryanDLS's advice and converted the whole thing to a full value pair setup, figuring having to go through most of the send and recieve code could cause me to "accidentally" fix it.

There was an unencoded Carriage Return/Line Feed in the code that didn't show up in the sample I pasted. I have no idea why it worked locally, but it was breaking the ajax somewhere inside the process.
That revealed a half dozen other issues (id:6 not id:"6", etc...) but all of those have been easy to resolve again ...and now it is working fine.

Thanks for the assist.