如何在spring中使用jqgrid将数据从jsp页面发送到控制器

时间:2012-10-07 04:45:25

标签: spring jqgrid

var pid = $('#byId').val();

jQuery("#patient").jqGrid({
    mtype: 'GET',
    url : "totalPatientList.html",
    postData :{pid:pid},
    datatype : "json",
    colNames : [ 'Patient Id', 'Name', 'BirthDate', 'Address','City','Mobile' ],
    colModel : [ {
        name : 'patientId',
        index : 'patientId',
        width : 55
    }, {
        name : 'name',
        index : 'name',
        width : 200
    }, {
        name : 'birthdate',
        index : 'birthdate',
        width : 100,
        editable : true
    }, {
        name : 'address',
        index : 'address',
        editable : true,
        width : 80
    }, {
        name : 'city',
        index : 'city',
        editable : true,
        width : 80
    }, {
        name : 'mobile',
        index : 'mobile',
        editable : true,
        width : 80
    } ],
    rowNum : 10,
    rowList : [ 5, 10, 30 ],
    pager : '#pager',
    sortname : 'id',
    viewrecords : true,
    sortorder : "desc",
    caption : "Search Patient's List",
    width : 800,
    cellEdit : true,
});

我有一个像上面这样的代码。

我想从此JSP页面向控制器发送pid。我正在获取pid,但是当我重新加载我的网页时。当我点击按钮时,我想要它而不重新加载页面。

我该怎么做?

PLZ PLZ帮助我......

1 个答案:

答案 0 :(得分:0)

您应该使用postData

的“功能”样式
url: "totalPatientList.html",
postData: {
    pid: function () {
        return $('#byId').val();
    }
}

如果pid参数的值将在每次向服务器发出请求时进行新评估。有关详细信息,请参阅the answer。通过在postData对象中包含多个方法,您可以将多个参数发送到服务器。