0

I have a hash map dataFields = {"element1":1,"element2":2,"element3":3} and I am trying to display the data in a dojo grid. However, when I set up my data store like:

    var data = {  identifier: "element1",
                  items: []
                };
   payload = JSON.stringify(dataFields);
   data.items.push(payload);  
   var store = new dojo.data.ItemFileWriteStore({data: data});   

the grid does not display anything. Now I know that the grid is set up correctly because when I pass in a JSON file to test my grid it displays the contents of the file without any errors. I should mention that dataFields is a response of a GET and the entire response is not useful to me that is why I extract the useful fields and put them in a hash map and try to display them. I feel like I am missing something essential here regarding how the data stores work. So I guess, the right question to ask is, how would I setup my data store so that the grid displays my hash map? Or is there a better way to do it than using a hash map?

Core7s
  • 147
  • 4
  • 13

1 Answers1

0

So it turns out that I did not need to 'stringify' the hash map. I just put in data.items.push(datafields) and it worked. The only reason I was doing it because I thought if I make it a string then it would imitate a JSON object. Turns out I was wrong because JSON text is kind of a hash map.

Core7s
  • 147
  • 4
  • 13