This project is read-only.

This project was born out frustration trying to use ExtJS 4 with .Net Web Services (.asmx) or WCF Services and the EntityFramework.

I hope this helps you get started quickly with you ExtJS and .Net project, examples to follow when I have the time for now it should be as simple as :-

Inherit from JsonHandler

public class OrderHandler: JsonHandler

Implement a method to response a URL

Description("/CreateOrder.json")
public object CreateOrder(Order body)
{
return _orderProvider.CreateOrder(body).Serialize("*");
}

If the store will post data, then your parameter must be called body.

If you want to control what data is returned make use of the Serialize extension method, * will serialize all non IEnumerable properties.
Otherwise specify what properties you want to return, for example
return _orderProvider.CreateOrder(body).Serialize("Id,OrderNumber");

would cause only the Id and OrderNumber properties to be returned.

If you want to return a complex property you can specify it like so
return _orderProvider.CreateOrder(body).Serialize("Id,OrderNumber>Customer,Id,Name<Product>Id,Name");

This will return the order Id and OrderNumber, the Customer Id and Name and Product Id and Name.

Reading

This is a sample signature for a method that would be used by a store when reading data.

Description("/ReadOrder.json")
public JsonResponse ReadOrder(int? id, int? page, int? start, int? limit, Filter[] filter, Sort[] sort)
{
var result = _orderProvider.ReadOrder(id, page, start, limit, filter, sort);
return new JsonResponse { data = result.Item1.Select(t => t.Serialize("*")), total = result.Item2 };

Finally add a Handler

  <system.webServer>    <handlers>      <add path="*.json" verb="*" type="Example.OrderHandler" name="OrderHandler" />    </handlers>  </system.webServer>

Last edited Jun 18, 2011 at 1:38 PM by IkSan, version 2

Comments

No comments yet.