如何使用新的查询字符串值重新加载jqGrid

时间:2014-02-09 16:31:47

标签: jqgrid

我使用onchange事件加载带有下拉值的jqgrid。

但是当我再次选择其他值时,我需要jqgrid来显示相应的值。

这是我如何加载jqgrid

    function getGrid() {

var mOptometrist = $('#optOptometristList').val();// Drop down value

alert(mOptometrist);

//jQuery("#list").jqGrid().setGridParam({ url: 'Schedule.ashx?mOptometristId=' + mOptometrist + '' }).trigger("reloadGrid");    


jQuery("#jQGridDemo").jqGrid({
    url: 'Schedule.ashx?mOptometristId=' + mOptometrist + '',
    datatype: "json",
    colNames: ['Id', 'Day', 'Start Time', 'End Time', 'Interval', 'Session', "Patient", 'Slots', 'Room Number'],
    colModel: [
                    { name: 'SlNo', index: '_id', width: 20, stype: 'text', editable: true, editoptions: { disabled: true} },
                    { name: 'DayOfWeek', index: 'Day', width: 150, stype: 'text', sortable: true, editable: true, edittype: "select", formatter: 'select', editoptions: { value: getAllSelectOptions()} },
                    { name: 'StartTime', index: 'StartTime', width: 150, editable: true, formatter: 'date', formatoptions: { srcformat: 'u', newformat: 'H:i:s'} },
                    { name: 'EndTime', index: 'EndTime', width: 60, editable: true, formatter: 'date', formatoptions: { srcformat: 'u', newformat: 'H:i:s'} },
                    { name: 'Interval', index: 'Interval', width: 80, align: "right", editable: true },
                    { name: 'Session', index: 'Session', width: 40, align: "right", editable: true },
                    { name: 'PatientsPerSlot', index: 'Patient', width: 80, align: "right", editable: true },
                    { name: 'Slots', index: 'Slots', width: 150, sortable: false, editable: true },
                    { name: 'RoomID', index: 'RoomNumber', width: 100, sortable: false, editable: true }
                  ],
    rowNum: 10,
    mtype: 'GET',
    loadonce: false,
    rowList: [10, 20, 30],
    pager: '#jQGridDemoPager',
    sortname: '_id',
    viewrecords: true,
    sortorder: 'desc',
    caption: "List Employee Details",
    editurl: 'Schedule.ashx?mOptometristId= ' + mOptometrist,
    loadComplete: function () {

        $("#jQGridDemo").setColProp('Day', { editoptions: { value: "1:Sunday;2:Monday;3:Tuesday"} });


    }
});

1 个答案:

答案 0 :(得分:1)

您可以使用

url: "",
postData: {
    mOptometristId: function () {
        return $('#optOptometristList').val();
    }
}

而不是

url: 'Schedule.ashx?mOptometristId=' + mOptometrist + ''

onchange活动内,您只需致电$("#jQGridDemo").trigger("reloadGrid");。有关详细信息,请参阅the answer