Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 Side 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 '<a href=\"Details/' +
                                oObj.aData[0] + '\">' + oObj.aData[0] +'</a>';
                            }
                        },
                        { "sName": "Agency_Name" },
                        { "sName": "COPSAuditNumber" },
                        { "sName": "OIGAuditNumber" }
                    ]
        });
    });

</script>

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(),
                <a href="/ref#aaData">aaData</a> = (
                from n in results
                select new[]
                {
                    n.Agency_Ori,
                    n.Agency_Name,
                    n.COPSAuditNumber,
                    n.OIGAuditNumber
                }).ToArray()
            },
            JsonRequestBehavior.AllowGet);
        }
share|improve this question
    
    
Thank you exactly what I needed. –  Chaka Jun 1 '13 at 12:24
    
one last thing: how do I access the values from mvc: –  Chaka Jun 3 '13 at 13:41
    
the client side its: "fnServerParams": function ( aoData ) { aoData.push( { "name": "more_data", "value": "my_value" } ); } –  Chaka Jun 3 '13 at 13:41
    
How do I get aoData? –  Chaka Jun 3 '13 at 13:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.