如何将选定的行id传递给jqGrid中的子网格的url

时间:2012-10-10 15:58:16

标签: jqgrid

我需要将一个额外的参数(即选定的row_id)传递给我用来显示子网格的网址。但Firebug控制台面板显示没有传递额外参数。 (当然服务器端代码也没有收到它。)

以下是我的代码,

myGrid.jqGrid({
    url: 'server.php',
    datatype: "json",
    mtype: 'POST',
    width: 900,
    height:500,
    sortname: 'productid',
    viewrecords: true,
    sortorder: "desc",
    caption: "JSON Example",
    rowNum: 100,
    subGrid: true,
    colNames: ['Product Id', 'Product Name', 'Supplier Id', 'Unit Price'],
    colModel: [
        {
        name: 'productid',
        index: 'productid',
        search: true,
        width: 55
    }, {
        name: 'productname',
        index: 'productname',
        width: 90,
        search: true
    }, {
        name: 'supplierid',
        index: 'supplierid',
        width: 100,
        search: false
    }, {
        name: 'unitprice',
        index: 'unitprice',
        width: 80,
        search: false,
        align: "right",
        search: true
    }
    ],

    subGridRowExpanded: function (subgrid_id, row_id) {
        var subgrid_table_id, pager_id;
        subgrid_table_id = subgrid_id + "_t";
        pager_id = "p_" + subgrid_table_id;
        $("#" + subgrid_id)
                .html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + pager_id + "' class='scroll'></div>");
        jQuery("#" + subgrid_table_id)
                .jqGrid({
                    url: "server.php",
                    datatype: "json",
                    colNames: ['Product Id', 'Product Name'],
                    width:700,
                    colModel: [{
                        name: 'productid',
                        index: 'productid',
                        width: 55

                    }, {
                        name: 'productname',
                        index: 'productname',
                        width: 90
                    }],
                    rowNum: 20,
                    sortname: 'num',
                    sortorder: "asc"
                    data: {prodcutid: row_id}

                });
    }

如何将选定的行ID传递给子网格的网址?

由于

1 个答案:

答案 0 :(得分:2)

data parameter在jqGrid中与jQuery.ajax中有另一种含义。所以你应该替换

data: {prodcutid: row_id}

在SubGrid中

postData: {prodcutid: row_id}