Group by an Item and send seperate ajax request
I am using .Net MVC application and jquery.I have list of OrderLines returning to the View
Structure of OrderLine will be
public class OrderLine
{
public string OrderNumber { get; set; }
public string PartNumber { get; set; }
public string QuantityOrdered { get; set; }
}
I have to display in the view in a table as order lines. There will be button at the bottom. Onclicking the button, I need to group the order lines by OrderNumber and then submit each order('NOT each order line') as ajax request to the action method at a time.
Can any one tell, what is the best way to do this?
I need to post the data in the following structure
public class Order
{
public string OrderNumber { get; set; }
开发者_开发百科 public List<OrderLine> orderLines { get; set; }
}
Action Method Signature will
Public ActionResult Update(Order order)
Thanks.
You can implement custom model binder with IModelBinder
and convert your OrderLine
posted values into Order
parameter to Update Action method.
Example: http://buildstarted.com/2010/09/12/custom-model-binders-in-mvc-3-with-imodelbinder/
Best Practices when Implementing IModelBinder Best Practices when Implementing IModelBinder
精彩评论