1

row_idサブグリッドを表示するために使用している URL に、追加のパラメーター (つまり、 selected ) を渡す必要があります。ただし、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 をサブグリッドの URL に渡す方法は?

ありがとう

4

1 に答える 1

2

このdata パラメーターは、jqGrid では のように別の意味を持ちますjQuery.ajax。だから交換すればいい

data: {prodcutid: row_id}

サブグリッドで

postData: {prodcutid: row_id}
于 2012-10-10T16:15:02.577 に答える