开发者

Group by an Item and send seperate ajax request

开发者 https://www.devze.com 2023-03-05 04:41 出处:网络
I am using .Net MVC application and jquery.I have list of OrderLines returning to the View Structure of OrderLine will be

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

0

精彩评论

暂无评论...
验证码 换一张
取 消