Sorting with MVCContrib
I have public class X { public List ListY { get; set; } }
public class Y { publi开发者_运维百科c Y();
public decimal Amount { get; set; }
}
I am showing the value of Amount in the grid. How to sort on this column. Is there a way to access this column to apply sort?
Thanks in advance Upendra
In your view, you should have something like this:
<%= Html.Grid(Model.PagedList).Columns(col => {
col.For(l => l.Amount).Named("Amount");
/* other columns here */
}).Sort(Model.GridSortOptions) %>
In your controller action, you would have something like this:
public ActionResult Index(GridSortOptions gridSortOptions)
{
//Code
}
You can download a complete MvcContrib Grid sample here:
http://www.codeproject.com/KB/aspnet/Grid_Paging_In_MVC3.aspx
You will see how you can implement sorting using MvcContrib Grid.
精彩评论