poddroid
poddroid

Reputation: 855

How to pass the selected row id to the subgrid's url in jqGrid

I need to pass an extra paramter (i.e. the selected row_id) to the url that I am using for to show the sub grid. But Firebug console panel shows no extra parameter been passed. (of course the server side code is also not receiving it).

Below is my code,

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}

                });
    }

How to pass the selected row id to the subgrid's url?

Thanks

Upvotes: 1

Views: 3150

Answers (1)

Oleg
Oleg

Reputation: 221997

The data parameter has another meaning in jqGrid as in jQuery.ajax. So you should replace

data: {prodcutid: row_id}

in the SubGrid to

postData: {prodcutid: row_id}

Upvotes: 2

Related Questions