PDA

View Full Version : How to get JSON/XML from EditorGrid or Grid (or ListStore) to update rest service



rohitghatol
3 Sep 2010, 5:20 AM
Hi,
There is my scenario

I have a restful service (json) which provides CRUD functionality. I could load Grid from JSON Rest ful service.

Now, I am using a Editor Grid and I change the fetch data and want to update the rest ful service.
So I will catch event on either Grid/EditorGrid or ListStore and from there I will manually update restful service.

The main thing here is I want to get the JSON or XML of the row (which I originally fetched from restful service), so I can change it and sent an update back to server.

If some one could guide on this, I could make my crucial decision of making GXT as my rendering framework.

Cheers,
Rohit

BrendanC
3 Sep 2010, 12:17 PM
Once you have the ModelData for the row from the event, you can convert it to JSON for your server using something like this:

new JSONObject(Util.getJsObject(mymodeldata, 10))
getJsObject is part of GXT and JSONObject is part of GWT.