Get Data from Postgres to dojo data grid
I have been looking at many help topics but have a knowledge gap here... I
am trying to get data from postgres database into a dojo data grid. I
created a php file which outputs this (when called from web browser)
[["Storage","2300-1"],["Storage","2427-1"],["Storage","1338-1"],["Storage","984-1"],["Storage","977-1"],["Storage","976-1"],["Storage","2167-1"],["Storage","1746"],["Storage","865-1"],["Storage","830-1"],["Storage","25-1"]]
it uses this code..
$myarray = array();
while ($row = pg_fetch_row($result)) {
$myarray[] = $row;
}
header('Content-Type: application/json; charset=utf8');
$json= json_encode($myarray);
echo $json;
i then try to read it in with an .html file.
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.ready(function(){
// our test data store for this example:
var store4 = new dojo.data.ItemFileWriteStore({url:"myweb url to the
/pgJSON.php"});
// set the layout structure:
var layout4 = [
{ field: 'structname', name: 'structname', width: '200px' },
{ field: 'leasejoin', name: 'leasejoin', width: '50px' }
];
// create a new grid:
var grid4 = new dojox.grid.DataGrid({
query: { structname: '*' },
store: store4,
clientSort: true,
rowSelector: '20px',
structure: layout4
}, document.createElement('div'));
// append the new grid to the div "gridContainer4":
dojo.byId("gridContainer4").appendChild(grid4.domNode);
// Call startup, in order to render the grid:
grid4.startup();
});
</script>
</head>
<div id="gridContainer4" style="width: 400px; height: 200px;"></div>
</html>
i use firebug to see errors and it gives me a " [Exception... "Cannot
modify properties of a WrappedNative" " type error.
I guess i dont understand the json object is it formatted correctly? the
PHP file? If i understand the php file creates the formatted data for the
.html file to ingest and process into the grid so where am i going wrong?
not understanding the json or not understanding the grid?
thanks..
No comments:
Post a Comment