reading json with dojo to show in grid -


I read a JSON file from the server and protecting the whole day to see it through the dojo datagrid I am Please see the code snippet below and help me if possible:

The html file is:

  & lt; Head & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "../../_ static / js / dijit / themes / claro / claro css" /> & Lt; Style type = "text / css" & gt; Body, html {font-family: helvetica, ariel, non-serif; Font-size: 90%; } & Lt; / Style & gt; & Lt; Style type = "text / css" & gt; @import "../../_static/js/dojox/grid/resources/Grid.css"; @import "../../_static/js/dojox/grid/resources/claroGrid.css"; .dojoxGrid table {margin: 0; } Html, body {width: 100%; Height: 100%; Margin: 0; } & Lt; / Style & gt; & Lt; / Head & gt; & Lt; Body class = "claro" & gt; & Lt; Div id = "gridContainer4" style = "width: 100%; height: 100%;" & Gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; Script type = "text / javascript" src = "http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js" djConfig = "parseOnLoad: true" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" & gt; Dojo.require ("dojo.data.ItemFileReadStore"); Dojo.require ("dijit.form.ComboBox"); Dojo.require ("dijit.form.Button"); Dojo.require ("dojox.grid.DataGrid"); Dojo.require ("dojox.data.CsvStore"); Dojo.addOnLoad (function () {// Store our test data for this example: var store4 = new dojo.data.ItemFileReadStore ({url: "http: //localhost/test1.json"}) // layout set Structure: var layout 4 = [[field: 'abrr', name: 'title of movie', width: '200 pixels'}, {field: 'name', name: 'year', width: '50px'} Create a new grid: var grid4 = new dosox.grid.datgrid ({query: {abbr: '*'}, {field: 'capital', name: 'creator', width: 'auto'}] Store: store4, ClientSort: true, rowSelector: '20px', structure: layout 4}, document.createElement Add new grid to "div"); div "gridContainer4": dojo.byId ("gridContainer4"). AppendChild (Grid4.domNode); // call to render the grid, tirtup: grid4.startup (); }); & Lt; / Script & gt; & Lt ;! - Note: The following script tag is not intended for use in real world !! This is part of CodeGlass and when you use the code - you should remove it - & gt; & Lt; Script type = "text / javascript" & gt; Dojo.addOnLoad (function () {if (document.pub) {document.pub ();}}); & Lt; / Script & gt;  

json is ::

  {identifier: 'abbr', label: 'name ',': '[Egypt], Capital:' Cairo '}, [ABBR:' S ',' Ab ' , 'El Salvador', Capital: 'San Salvador'}, {ABRB: 'GC', name: 'Equatorial Guinea', Capital: 'Malabo'}, {ABB: 'er', name: 'Eritrea' Capital: 'Osman'), {ABRB: 'AE', name: 'Estonia', Capital: 'Tallinn'}, {ABBR: 'et', name: 'Ethiopia' , Capital: 'Addis Ababa'}]}  

I'm not using dojo But if test1.json's file content is actually as you wrote at the end of your post, then it is wrong. All property names in the format and all strings should require double questions. Try changing the test1.json file with the following:

  {"identifier": "abbr", "label": "name", "items": [{"abbr": "" "Egypt", "Capital", "Salvador", "Capital", "Capital" "", "" Cameron "," ABRR "," Ecuador "," Capital ":" Quito "}, {" ABRR ":" Example "," Name " : "EBR": "EAR", "NOM": "ERRR": "GC", "Named": "Equatorial Guinea", "Capital": "Malabo"}, "Ebb": "Eritrea" "Elysium": "E.E.", "Name": "Estonia", "Capital": "Tallinn" Ebb ":" At "," Name ":" Ethiopian " Security "," Capital ":" Addis Ababa "}]}  

A good place where you JSON data can your valid.


Comments