PDA

View Full Version : Ok...all attempts with JsonReader failed. [Solved]



Fredric Berling
12 Jun 2008, 12:59 AM
im trying to use jsonReador to fill a grid in my form. I have narrowed the code down to be as simple as possible. There must be something basic im doing wrong here. The grid shows up with correct columns but with NO data.

My form "testgrid" looks like this (Passthrue html):

<div style="margin-left:100px;margin-top:50px">
<div id="file-grid" style="border:1px solid #99bbe8;overflow: hidden; width: 400px; height: 300px;"></div>
</div>

My form "testgrid" have this code in the onLoad event


var jsonReader;
var myDataStore;

Ext.onReady(function()
{
jsonReader = new Ext.data.JsonReader({
root: 'root',
totalProperty: 'recordcount',
id: 'id',
fields: ['id','name']
});

myDataStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'testdata?openAgent',
method: 'POST'
}),
reader: jsonReader,
autoLoad: true,
remoteSort: false
});

var grid = new Ext.grid.GridPanel({
renderTo:'file-grid',
store:myDataStore,
columns: [
{header: "id", width: 100, resizable: false, dataIndex: 'id'},
{header: "name", width: 220, resizable: false, dataIndex: 'name'}],
viewConfig: {
forceFit: true
},
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
width:600,
height:300,
frame:true,
title:'Test',
iconCls:'icon-grid'
});

grid.render();
})

my testdata agent looks like this:

Sub Initialize
Msgbox "agent started"
Print "Content-type:text/html; charset=UTF-8"
Print |Cache-control: no-cache, no-store, must-revalidate|
Print |{"recordcount":"3","root":"[|
Print |{"id":"1", "name":"test1"},|
Print |{"id":"2", "name":"test2"},|
Print |{"id":"3", "name":"test3"}|
Print |]"}|
Msgbox "agent done"
End Sub

nicklepedde
12 Jun 2008, 3:15 AM
Looking at your JSON


Print |{"recordcount":"3","root":"[|

Print |{"id":"1", "name":"test1"},|

Print |{"id":"2", "name":"test2"},|

Print |{"id":"3", "name":"test3"}|

Print |]"}|


Try removing the quotes for the root value, like:


Print |{"recordcount":"3","root":[|

Print |{"id":"1", "name":"test1"},|

Print |{"id":"2", "name":"test2"},|

Print |{"id":"3", "name":"test3"}|

Print |]}|

Fredric Berling
12 Jun 2008, 3:50 AM
That was it..I must have tried just about everything except that. You are the man!

Yaether
12 Jun 2008, 6:35 AM
Hi Fredric,

I tried your code with corrections made..but maybe i'm missing something..

when in firefox, I get the "H has no properties" from ext-all.js (line 76) in firebug console,
when in ie7, I get
Line: 77
Char: 1950
Error: 'null" is null or not an object
Code: 0
URL: myurl/mynsf.nsf/testgrid

Any ideas??

Fredric Berling
12 Jun 2008, 7:54 AM
Hi Fredric,

I tried your code with corrections made..but maybe i'm missing something..

when in firefox, I get the "H has no properties" from ext-all.js (line 76) in firebug console,
when in ie7, I get
Line: 77
Char: 1950
Error: 'null" is null or not an object
Code: 0
URL: myurl/mynsf.nsf/testgrid

Any ideas??

hmm.. i remember getting something similiar when i was testing. Can you use ext-all-debug.js instead to get a better error message?

Yaether
13 Jun 2008, 3:27 AM
hmm.. i remember getting something similiar when i was testing. Can you use ext-all-debug.js instead to get a better error message?

Thanx for ur reply. I used the debug switch and now i get in firefox the error .
"ct has no properties".
Fredric, I must say I'm newbie when it comes to javascript..Please see the attachment for more info about the error..Maybe u can make a point!

Fredric Berling
13 Jun 2008, 5:17 AM
Thanx for ur reply. I used the debug switch and now i get in firefox the error .
"ct has no properties".
Fredric, I must say I'm newbie when it comes to javascript..Please see the attachment for more info about the error..Maybe u can make a point!

It seems like the DXLexporter agent is throwing the error. I would suggest opening the form using the direct url to it (./testgrid?Openform ) . That agent should not be running then.
In my simple testform i included the Ext paths and Init stuff in the [HTMLHeader].