PDA

View Full Version : How to do CRUD operation using Grid with JSON Rest ful service



rohitghatol
1 Sep 2010, 11:03 AM
Hi All,
I am not sure what I am missing here.

I have a rest ful json service. I am able to load data from it to show it in a Grid using following code

// use a http proxy to get the data
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, GWT
.getHostPageBaseURL()
+ "json/employee/get/all");
HttpProxy<String> proxy = new HttpProxy<String>(builder);

// need a loader, proxy, and reader
JsonLoadResultReader<ListLoadResult<ModelData>> reader = new JsonLoadResultReader<ListLoadResult<ModelData>>(
type);

final BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(
proxy, reader);

ListStore<ModelData> store = new ListStore<ModelData>(loader);
final EditorGrid<ModelData> grid = new EditorGrid<ModelData>(store, cm);


I want to now update the json rest ful service using Grid. Say user adds a new row in grid, it should fire a post request with json snippet to the json rest ful service, similar thing for update and delete operations.

How can I do that?

In ExtJs I was that when you create a HTTPProxy you can specify different urls for CRUD Operations. How to go about doing that in EXT GWT?

Cheers,
Rohit

sven
1 Sep 2010, 11:05 AM
Nothing like this is directly integerated to GXT.

You will need to listen to the Add event of the ListStore (for example) and start your request to the server manually.

rohitghatol
1 Sep 2010, 11:20 AM
Fine, fair enough

Now I want to know would GXT help me atleast in creating the json string from grid's row? Or will I have to create the json by hand


Also, is there any reference or example of CRUD Editable Grid working with either json/xml restful service, so I can replicate my code from there.

pwanner
6 Feb 2012, 6:37 AM
Hi,

I'm wondering if in the Ext-GWT 3.0 stores there will be the same Rest CRUD fonctionality as in the ExtJS one?

If not, why? and how to achieve this easyly?

Cheers.

gxt_developer
12 May 2012, 12:47 PM
What is the standard way of calling a RESTful service from a listener in GXT?