How to load a subgrid statically?

I don't want use ajax to load data in my grid. Theres a way to load all data to main grid and subgrids statically?

In the samples from jqGrid Documentation, the parameter subGridUrl, is needed. But I want something like:

var mydata = [ {
// ... some static code for data creation here
 } ]

and using mydata in parameter data, but subGrid don't have this parameter or something else.



If you use subgrid as grid you have to create new grid inside of subGridRowExpanded callback. The callback get rowid as a parameter. So if you would get the array of data which can be used as data parameter of the subgrid the subgrid can be defined with datatype: 'local'.

The code schema can be about the following:

var mainGridData = [
        {id: 'm1', ...},
        {id: 'm2', ...},
    subgridData1 = [
        {id: 's11', ...},
        {id: 's12', ...},
    subgridData2 = [
        {id: 's21', ...},
        {id: 's22', ...},
    subgridByMainGridId = {
        m1: subgridData1,
        m2: subgridData2

        datatype: 'local',
        data: mainGridData,
        subGrid: true,
        subGridRowExpanded: function(subgridId, rowId) {
            var subgridTableId = subgridId + "_t";

            $("#" + $.jgrid.jqID(subgridId)).html('<table id="' +
                subgridTableId + '"></table>');
            $("#" + $.jgrid.jqID(subgridTableId)).jqGrid({
                datatype: 'local',
                data: subgridByMainGridId[rowId],


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.