Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82131

MVC how do you pass parameter values?

$
0
0
I have 2 filter text boxes:
<input type="text" id="ORI">
<input type="text" id="AgencyName">

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


client code:
<script type="text/javascript" charset="utf-8">
    $(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 '<a href=\"Details/' +
                                oObj.aData[0] + '\">' + oObj.aData[0] +'</a>';
                            }
                        },
                        { "sName": "Agency_Name" },
                        { "sName": "COPSAuditNumber" },
                        { "sName": "OIGAuditNumber" }
                    ]
        });
    }); 

</script>

My controller:
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<AuditAgency> 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);
        }

Viewing all articles
Browse latest Browse all 82131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>