ASP .NET MVC - View and Controller communication

ASP .NET MVC - View and Controller communication

innuendoinnuendo Posts: 3Questions: 0Answers: 0
edited September 2011 in General
In my view I have:

[code]$(document).ready(function () {
$('#tblData').dataTable({
"bProcessing": true,
"bServerSide": true,
"aoColumnDefs":
[
{ "mDataProp": "Phone", "aTargets": [0] },
{ "mDataProp": "Email", "aTargets": [1] },
],
"sAjaxSource": "/Administration/GetUsers",
});
});[/code]

And in my Controller:

[code][HttpGet]
public JsonResult GetUsers()
{
FarmerEntities db = new FarmerEntities();

var users = from u in db.Users
select new
{
Phone = u.Phone,
Email = u.Email
};

var outJson = new
{
sEcho = "1",
iTotalRecords = users.Count(),
iTotalDisplayRecords = users.Count(),
aaData = users
};

return Json(outJson, JsonRequestBehavior.AllowGet);
}[/code]

Now I would like to implement sorting (not by putting it into initialization code but rather by user clicking on any column). How can I do that?
This discussion has been closed.