0
votes

I'm trying to add subgrids to an existing jqGrid.

When I expand a parent row, the URL is called and the JSON response looks good (to my eyes) but it is not being bound to the sub grid rows.

If I call the web service directly by pasting the URL in a browser, the response looks good.

This is the full jqGrid definition:

            /* +++ Group Grid Definition +++ */
            $("#<%= id %>_groupTable").jqGrid({
                loadonce: true,
                datatype: 'local',
                //sortable: true,
                gridview: true,
                editurl: "clientArray",
                autowidth: true,
                rowNum: 12000,
                height: 150,
                multiselect: false,
                hidegrid: false,
                pgbuttons: false,
                pginput: false,
                sortname: "Date",
                sortorder: "desc",
                jsonReader: {
                    root: "inbox",
                    page: "page",
                    total: "total",
                    records: "records",
                    id: "id",
                    repeatitems: false,
                    subgrid: { repeatitems: true }
                },
                toolbar: [true, "bottom"],
                colModel: [
                {
                    name: 'userGroupId',
                    label: '{{VIEW_LABEL}}',
                    index: 'userGroupId',
                    width: 50,
                    fixed: true,
                    hidden: true,
                    //sortable: false,
                    align: 'center'
                }, {
                    name: 'desc',
                    label: '{{NAME_LABEL}}',
                    index: 'desc',
                    width: 130,
                    align: 'center',
                    sorttype: 'text'
                }],
                hidegrid: false,
                gridComplete: function () {
                    $('#<%= id %> .loading').remove();
                    $('#<%= id %>_groupTable').jqGrid('setSelection', 1);
                },
                loadComplete: styleGroupRows,
                afterInsertRow: styleGroupRows,
                subGrid: true,
                subgridtype: 'json',
                subGridUrl: '/ws/users/groupusers',
                subGridModel: [
                    {
                        name: ['Name'],
                        width: [200],
                        params: ['userGroupId']
                    }]
            }).jqGrid('bindKeys', {
                'scrollingRows': true
            });

This is the JSON response from the web service:

{'rows':['User 1312','User 1316','User 1286','User 1149']}

I'm expecting a single column of user names in the sub grids but only the column headers appear.

1

1 Answers

0
votes

Your subGrid response does not match the rules.

Try with the following response:

{"rows":[{"id":"1","cell":["User 1312"]},{"id":"2","cell":["User 1316"]}]}