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