0

I am trying to do simple thing with JQgrid. I have a page with textboxes(firstname, lastname etc). I enter values for these textboxes and I make a get call on button click event to get the data from controller and show in Grid. First time it works just fine. but second time when i change value in textbox the value of the parameter gets updated as per textbox on view side but on controller side the value of parameter does not get updated.

For example, first time i pass value as lastname ="XYZ" that works fine but when i pass value as lastname = "BCC" it still shows XYZ. Why is that?

Below is my code. what am i doing wrong?

function Search() {
    var fName = $("#txtFName").val();
    var lName = $("#txtLName").val();
    var city = $("#txtCity").val();
    var state = $("#txtState").val();
    var zip = $("#txtZip").val();
    var dob = $("#txtDOB").val();
    var driverLic = $("#txtDrvierLic").val();
    var playerID = $("#txtPlayerID").val();


    var imurl = "/Home/GetPlayerInformationGrid/?fName=" + fName + '&lName=' + lName + '&city=' + city + '&state=' + state + '&zip=' + zip + '&dob=' + dob + '&driverLic=' + driverLic + '&playerID=' + playerID;


    $("#list").jqGrid({
        url:imurl,
        width: 650,
        datatype: 'json',
        mtype: 'GET',
        colNames: ['FirstName', 'PlayerID', 'Date Of Birth', 'State'],
        colModel: [
          { name: 'FirstName', index: 'FirstName', width: 100, align: 'center' },
          {
              name: 'PlayerID', index: 'PlayerID', width: 100, align: 'center', edittype: 'select', formatter: playerFormatter
          },
          { name: 'DOB', index: 'DOB', width: 100, align: 'center' },
          { name: 'State', index: 'State', width: 100, align: 'center' }
        ],
        pager: '#pager',
        rowNum: 10,
        rowList: [10, 20, 30],
        sortname: 'invid',
        sortorder: 'desc',
        viewrecords: true,
        gridview: true,
        height: "auto",
        caption: 'List of Players',
        loadonce: false

    }).trigger("reloadGrid");

    jQuery("#list").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, refresh:true });

}

2 Answers 2

1

create the grid once with default criteria, let say, in document.ready function. Then reload it using the following approach in your search function.

var imurl = "/Home/GetPlayerInformationGrid/?.......
jQuery("#list").jqGrid('setGridParam',{url:imurl,datatype:'json'}).trigger("reloadGrid",[{page:1}]);
0

Are you setting any of your values in session (controller)? If doing so properly reset the session values once every request completed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.