开发者

jqgrid re-initialization

I need to find a way to modify grid parameters. Let me better explain the scenario. I have two jqGrid object on my page both calling a remote web service function that feeds the data. The first object is the main grid and when the user click on a button that is inside a column the application shows a dialog, with the second grid inside.

The second grid to shall contains some data that is related to a field contained in the first grid selected row. So the code I have actually is the following:

function showDialog(customerID, wsBaseUrl, sl) {
    var title = "";
    var dlg = $("#pclist");
    //Set the title with the value returned
    dlg.dialog("option", "title", title);
    createGrid(customerID, wsBaseUrl, sl);
    //Open the dialog
    dlg.dialog('open');
}

function createPCGrid(customerID, wsBaseUrl) {
    var pc_grid = $('#pcgrid');
    pc_grid.jqGrid({
        url: wsBaseUrl开发者_运维知识库 + 'GetOrderList',
        colNames: ['OrderID', 'Order Date', 'Qty', 'Unit', 'Line total'],
        colModel: [
            //omitted for brevity
        ],
        jsonReader: {
            id: "OrderID"
        },
        serializeGridData: function (postData) {
            if (postData.filters === undefined) postData.filters = null;
            if (postData.customerID === undefined) postData.customerID = customerID;
            return JSON.stringify(postData);
        },
        pager: $('#pcgrid_pager'),
        sortname: 'OrderID',
        sortorder: "asc",
        height: '280',
        rownumbers: true,
        gridview: true
    });
}

As you can see I am re-creating, each time a click has been done, a grid object and binding it's parameter customerID on the list of params that will be sent to the server by the grid in its serializeGridData function event.

Unfortunately this does not work and the initial param does never get changed.

Maybe I am not doing it correctly anyway. Is there any way to re-initialize the grid or to pass params to the grid to be serialized in its subsequent requests as in my sample?

Thanks for helping


I suppose that the dialog will be hidden and not destroyed after you close it. So you can include call of $("#pcgrid").jqGrid('GridUnload') before assigning of pc_grid = $('#pcgrid').

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜