MVC how do you pass parameter values?

MVC how do you pass parameter values?

cmanvacmanva Posts: 37Questions: 0Answers: 0
edited May 2013 in General
I have 2 filter text boxes:



How do I pass these values to my controller below? How do I access them from controller "GetAgencies()"?


client code:
[code]

$(document).ready(function () {

$('#agencyList').dataTable({
"bServerSide": true,
"sAjaxSource": "GetAgencies",
"bProcessing": true,
"iDisplayLength": 10,
"bLengthChange": false,
"bFilter": false,
"aoColumns": [
{ "sName": "Agency_Ori",
"bSearchable": false,
"bSortable": false,
"fnRender": function (oObj) {
return '' + oObj.aData[0] +'';
}
},
{ "sName": "Agency_Name" },
{ "sName": "COPSAuditNumber" },
{ "sName": "OIGAuditNumber" }
]
});
});


[/code]

My controller:
[code]
public ActionResult GetAgencies(jQueryDataTableParamModel param)
{
AuditDAL ad = new AuditDAL();
var agencies = ad.SearchAgencies("Ak001", "");

string col = param.sColumns.Split(',')[param.iSortCol_0];
string orderby = col + " " + param.sSortDir_0;

IEnumerable filteredAgencies = agencies;

var results = filteredAgencies
.Skip(param.iDisplayStart)
.Take(param.iDisplayLength);

return Json(new
{
sEcho = param.sEcho,
iTotalRecords = agencies.Count(),
iTotalDisplayRecords = filteredAgencies.Count(),
aaData = (
from n in results
select new[]
{
n.Agency_Ori,
n.Agency_Name,
n.COPSAuditNumber,
n.OIGAuditNumber
}).ToArray()
},
JsonRequestBehavior.AllowGet);
}
[/code]

Replies

  • psharppsharp Posts: 39Questions: 0Answers: 0
    edited May 2013
    [quote]cmanva said:
    [code]aaData[/code][/quote]

    Your aaData parameter appears to be malformed. This should be a json encoded key name, not an href tag.
  • cmanvacmanva Posts: 37Questions: 0Answers: 0
    Copy and paste..some reason..it came out as a link? Its correct locally.
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Not sName - use mData . See http://datatables.net/blog/Extended_data_source_options_with_DataTables

    Allan
This discussion has been closed.