views:

30

answers:

1

Hi all,

I have a clarification in loading JSON String into Listgrid in GWT. I have implemented GWT-RPC, so from server side JSON string will be returned and have mapped it to grid fields properly.

My JSON String looks like

return "[ { user: { User ID: 1, name: abc},
initial:A,
},
{ user: { User ID: 2, name: xyz},
initial:B,
}
]";

The problem now here was initial field gets loaded with A & B . but the nested fields such as User ID & name are not getting loaded.

I have setted value xpath for those fields. but its of no use.

Pls tell me how to render the user id & name fields. thanks in advance

Note: I am processing the JSON String from server like :

where result is the JSON String from server

JavaScriptObject obj=JSON.decode(result); Record[] record = ListGridRecord.convertToRecordArray(obj);

A: 

valueXPath is designed for exactly this use case, but it's only active if you use a DataSource, and you seem to be circumventing the DataSource layer. There is a very simple sample of using a DataSource with JSON and valueXPath here:

http://www.smartclient.com/smartgwt/showcase/#json_integration_category_xpath

Using this approach, you'll be able to delete a bunch of unnecessary GWT-RPC logic.

See also the QuickStart Guide for further information on data binding:

http://blog.isomorphic.com/?p=227

Charles Kendrick