xMilos
xMilos

Reputation: 2018

jqgrid grid columns to subgrid

I have the following code which works fine and creates the grid with 4 columns:

 $("#"+GRID).jqGrid({
            url:'ajax.htm',
            datatype: 'json',
            mtype: 'POST',
            jsonReader: { repeatitems : false, cell:"", id: "id", userdata: "jsonModel", root: "rows" },
            postData: {
                ajaxRequest: document.helper.getPageName(),
                screenMode: 'getList'
            },
            colNames:[
                'id'
                'listname',
                'customer'.
                'employee'.
                'sum'
            ],
            colModel:[        
                {name:'id', index:'id', editable:false, hidden: true},
                {name:'listname', index:'id', editable:false, hidden: true},
                {name:'customer', index:'customerColumn', editable:false, sortable:true},
                {name:'employee', index:'employeeColumn', editable:false, sortable:true},
                {name:'sum', index:'sum', editable:false, sortable:true}
            ],
            autowidth:true,
            shrinkToFit:true,
            rownumbers:true,
            pager:$('#'+GRID_PAGER),
            sortname: 'listname',
            sortorder: "desc",
            loadonce: true,
            rowNum:30,
            rowList:[10, 30, 50],
            viewrecords:true,
            gridComplete:function () {
                var data = $("#"+GRID).getGridParam('userData');

        })

This code have no subgrids.

Is it posible to edit this, so the grid will have only columns 'id' and 'listname', and on subgrid are 'customer','employee','sum'.

Does subgrid needs another ajax call?

I read that the following lines should be added

subGrid: true, subGridRowExpanded: function (subGridId, rowId) {}

Upvotes: 1

Views: 202

Answers (1)

MNJ
MNJ

Reputation: 192

http://trirand.com/blog/jqgrid/jqgrid.html see grid as subgrid demo, it is in the advanced tab.

Upvotes: 1

Related Questions