I am returning JSON from my java servlet and populating a datastore. Here is a snippet:
[{“address”:{“city”:“Boulder”,“personId”:0,“state”:“CO”,“street”:“7240 C
lubhouse Rd”,“zip”:{“zipcode”:“80301”}},
“birthdate”:“1970/10/06”,“firstName”:“Nick”,“id”:0,“lastName”:“Vujasin”,
“phoneNumbers”:[{“name”:“Cell”,“number”:“773-517-1735”,“personId”:0},
{“name”:“Home”,“number”:“720-678-9876”,“personId”:0}]},
{“address”:{“city”:“Chicago”,“personId”:1,“state”:“IL”,“street”:“1940 Crystal Ave.”,
“zip”:{“zipcode”:“60649”}},
“birthdate”:“1972/10/06”,“firstName”:“Pete”,“id”:1,“lastName”:“Tutera”,
“phoneNumbers”:[{“name”:“Home”,“number”:“312-558-2300”,“personId”:1}]}]
Here is the snippet of code that creates my grid:
// Create a grid object by attaching it to cell "a" of the layout. Attaching an object
// to another object creates the object being attached all in one step.
contactsGrid = layout.cells("a").attachGrid();
contactsGrid.setHeader("Name,Last Name,Email");
contactsGrid.setInitWidths("100,100,*");
contactsGrid.setColAlign("left,left,left");
contactsGrid.setColTypes("ro,ro,ro");
contactsGrid.setColSorting("str,str,str");
contactsGrid.setColumnIds("firstName,lastName,address.city");
// Add filtering to the grid.
contactsGrid.attachHeader("#text_filter,#text_filter,#text_filter");
// Initialize the grid.
contactsGrid.init();
contactsGrid.sync(myDataStore);
The first name and last name fields do show up in the grid but the address.city does not. Is there a way to show nested elements in the grid from a datastore?
Thanks
Nick