I am having great difficulty in feeding my json string to my dojo enhanced datagrid. Now basically I have a person entity which has a date-of-birth and a nationality. On the person Table nationality is a forign Key.
I am using spring 3.0 and here is my controller logic for producing the json string.
uiModel.addAttribute("studentasJSON", new JSONSerializer().serialize(students));
//students is a list of Student objects
Now if I print out the json string for one student we have this.
[{"class":"tt.edu.sbcs.model.Student","comment":null,"dateOfBirth":{"class":"java.util.GregorianCalendar","firstDayOfWeek":1,"gregorianChange":-12219292800000,"lenient":true,"minimalDaysInFirstWeek":1,"time":1069041600000,"timeInMillis":1069041600000,"timeZone":{"DSTSavings":0,"ID":"America/La_Paz","class":"sun.util.calendar.ZoneInfo","dirty":false,"displayName":"Bolivia Time","lastRuleInstance":null,"rawOffset":-14400000}},"ethnicOrigin":null,"firstName":"Goat","gender":"Male","id":5487,"lastName":"Dog","legacyID":null,"maritalStatus":"Single","nationality":{"class":"tt.edu.sbcs.model.Country","code":"BB","id":1,"name":"Barbados","version":262},"nativeLanguage":null,"otherName":"","photo":null,"religion":null,"title":{"class":"tt.edu.sbcs.model.Title","id":1,"name":"Mr.","version":0},"uniqueIdNumber":null,"version":0}]
This is where it gets complicated. The dojo enhancedgrid requires "dateOfBirth":"2003-11-17". Similarly,"nationality":"Barbados" and NOT the fully serialized Object. However, http://dojotoolkit.org/reference-guide/dojo/store.html speakes about the querying an existing datastore, but its not very clear how to use it. Can someone please advise?
I saw on http://forum.springsource.org/showthread.php?103331-Best-practices-with-Spring-Roo-JSON-and-Ajax they used the query attribute of the dojo enhanced grid to some how query the string. Something like
<table dojoType="dojox.grid.DataGrid"
jsid="grid" id="grid" class="grid" autoHeight="15" noDataMessage="Sorry, there is no data available."
store="jsonStore" query="{ name: '*' }" rowsPerPage="20" rowSelector="20px">
Can someone please advise on the use of the query attribute. It is impractical to manipulate the string after it is generated as there will be thousands of tuples and linkages to arbitrary entities in my system.