tags:

views:

170

answers:

2

I have ExtJS based application. I have compound object on the server side, and have ExtJS window with few tabs for editing different parts of this one object. For example:

I Have Compound object "Car"

public class Car
{
   public string Name;
   public string Color;

   public List<Wheel> Wheels;
   public List<Door> Doors;
}

And on my ExtJS window i have tabs ("General Info", "Wheels", "Doors") for editing different parts of this object.

So what i want:

When i want to create a new car i want to generate JSON configuration for my class "Car" like {Name:null; Color:null; Wheels:[]; Doors:[]} then sent it to the client, fill it on the client (without callbacks to server) and after user finishes creating his Car object (he added wheels, doors, set name and color) and press save, I want to sent this filled(generated) JSON object to server and save it to DB.

Is it possible?

Thanks

+1  A: 

Here how you can post a JSON object from JavaScript to the server using ExtJS:

var obj = {
   property1: "Value1",
   property2: [],
   property3: true
};
Ext.Ajax.request({
   url: 'some.url',
   method: "POST",
   callback: function(options,success,xhr) { console.dir(arguments); },
   jsonData: Ext.encode(obj)
});

Now how to handle that request depends on what you use on the server-side, but the POST buffer for this request would contain exactly this: {"property1":"Value1","property2":[],"property3":true}

SBUJOLD
A: 

you can also use Ext.Ajax.request with params: {param: Ext.decode(yourParamObject)}

show