0

I am attempting to actually get my jqGrid to load data on a button click... So far I have my button ready to be clickable as you can see. The problem is, I some how or the other not getting the navigation info correct... I am trying to AJAX call an that is set up using @HTML.BeginForm like so...

@using(Html.BeginForm("returnJSONEncoutnerData", "AddEncounter", new { popId = (int)TempData["POPULATIONID"]}, FormMethod.Post, new { id = "SearchPatID" }))

And here is my button click function.

$('#submit').click(function (event) {
        //alert("What the FONK is going on here!");
        debugger;
        var theURL = $("#SearchPatID").action;
        var type = $("#SearchPatID").methd;
        event.preventDefault();
        $.ajax({
            url: this.action,
            type: this.method,
            data: $(this).serialize(),
            dataType: "json",
            success: function (result) {
                bindCustomers();
            }
        });
        return false;
    });

My function bindCustomer is supposed to fill a jqGrid with JSON data that the above method collects and JSONifies! I thought I would put it out there to quench your curiosity.

 var bindCustomers = function () {
    alert('');
    $("#list").jqGrid({
        url: $("#DisplayUniqueEncounters").attr("action"), //'/Home/GridData/',
        gridview: false,
        shrinkToFit: false,
        autowidth: true,
        datatype: 'json',
        mtype: 'POST',
        colNames: ['Edit',
                   'MRN',
                   'Hospital Fin',
                   'First Name',
                   'Last Name',
                   'Date of birth',
                   'Completed Pathway',
                   'Completed Pathway Reason',
                   'PCP Appointment',
                   'Specialist Appointment',
                   'Admit Date',
                   'Discharge Date',
                   'Discharge Disposition',
                   'Discharge To',
                   'Discharge Advocate Call',
                   'Home Healthcare',
                   'Safe Landing Accepted',
                   'PCP Name',
                   'PCP Phone',
                   'PCP Appointment Location',
                   'Specialist Name',
                   'Specialist Phone',
                   'Specialist Appointment Location',
                   'Comments',
                   'Patient Room Phone',
                   'Phone',
                   'Payor',
                   'MRN Type'
                   ],
        colModel: [
                   { name: 'Edit', width: 95, align: 'left' },
                   { name: 'MRN', width: 125, align: 'left' },
                   { name: 'Hospital_Fin', width: 145, align: 'left' },
                   { name: 'First_Name', width: 115, align: 'left' },
                   { name: 'Last_Name', width: 115, align: 'left' },
                   { name: 'Date_of_birth', width: 145, align: 'left' },
                   { name: 'Completed_Pathway', width: 125, align: 'left' },
                   { name: 'Completed_Pathway_Reason', width: 165, align: 'left' },
                   { name: 'PCP_Appointment', width: 115, align: 'left' },
                   { name: 'Specialist_Appointment', width: 125, align: 'left' },
                   { name: 'Admit_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Date', width: 185, align: 'left' },
                   { name: 'Discharge_Disposition', width: 155, align: 'left' },
                   { name: 'Discharge_To', width: 85, align: 'left' },
                   { name: 'Discharge_Advocate_Call', width: 155, align: 'left' },
                   { name: 'Home_Health_Care_Accepted', width: 105, align: 'left' },
                   { name: 'Safe_Landing_Accepted', width: 165, align: 'left' },
                   { name: 'PCP_Name', width: 85, align: 'left' },
                   { name: 'PCP_Phone', width: 85, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'PCP_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Specialist_Name', width: 195, align: 'left' },
                   { name: 'Specialist_Phone', width: 135, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Specialist_Appointment_Location', width: 185, align: 'left' },
                   { name: 'Comments', width: 185, align: 'left' },
                   { name: 'Patient_Room_Phone', width: 135, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Phone', width: 125, formatter: formatPhoneNumber, align: 'left' },
                   { name: 'Payor', width: 155, align: 'left' },
                   { name: 'MRN_Type', width: 135, align: 'left' }
                   ],
        //pager: jQuery('#pager'),
        rowNum: 10,
        rowList: [5, 10, 20, 50],
        sortname: 'Id',
        sortorder: "desc",
        viewrecords: true,
        imgpath: '/scripts/themes/coffee/images',
        caption: 'My first grid'
    });
}

I need data to be thrown back at me asynchronously at some point. But beggers can't be chosers at this point. I need to figure out why I can't get the correct routing information.

SoftwareSavant
  • 8,456
  • 26
  • 107
  • 186

1 Answers1

0

this is the button, not the form.
It doesn't have an action.

You should handle the form's submit event instead, so that this will be the form.

SLaks
  • 800,742
  • 167
  • 1,811
  • 1,896