1

I having trouble populating a gridx widget from a JsonRest store. See my code below... test1.json contains the same info as i have specified in the data for teststore.

When i change the grid to point at the teststore var it displays the contents correctly but when i point it at the reststore variable i get a 'No items to display' message.

Anyone know what im missing?

var restStore = new   dojo.store.JsonRest({target:"http://localhost:9081/MyProj/test1.json"});


var teststore = new Store({
 data: [
 {id: "1", "description":"First Description"},
 {id: "2", "description":"Second Description"},
 {id: "3", "description":"Third Description"},
 {id: "4", "description":"Fourth Description"}
       ]
});



  grid = new Grid({
    cacheClass: Cache,
    store: restStore,
    structure: [
      {id: "description", field: 'description', width: '100%'}
    ]
  }); 

grid.startup();
blu10
  • 534
  • 2
  • 6
  • 28
  • 1
    Have you tried with an actual service, or only with a static JSON endpoint? That endpoint probably isn't going to set the Content-Range header as dojo/store/JsonRest expects, so that could be part of the problem... see http://dojotoolkit.org/reference-guide/1.9/quickstart/rest.html for more info. – Ken Franqueiro Nov 27 '13 at 22:48
  • Also note that you'll need to use `Async` cache (`gridx/core/model/cache/Async`). – twil Nov 27 '13 at 23:22
  • its a static end point.... thanks for the link... is there any quicj way to set the content range header so i can see it working with the static json?... – blu10 Nov 28 '13 at 09:16

1 Answers1

0

gridx and dojox.grid.DataGrid are not the same thing. dojox.grid.DataGrid is deprecated and only works with legacy dojo/data stores. You may use dojo/data/ObjectStore to wrap a dojo/store store with the dojo/data API:

var teststore = new ObjectStore({ objectStore: new Store({ … }) });

However, if you are starting a new project, you should use dgrid instead, which works natively with dojo/store stores.

C Snover
  • 17,908
  • 5
  • 29
  • 39
  • hi there, im trying to do this with gridx control... just finding a good example is very hard... – blu10 Nov 28 '13 at 09:17