jqGrid offers two ways of handling child records:
SubGrids use the following properties, events and methods of the parent grid.
| Property | Type | Description | Default |
|---|---|---|---|
| subGrid | boolean | If set to true this enables using a subgrid. If the subGrid is enabled a additional column at left side is added to the basic grid. This column contains a 'plus' image which indicate that the user can click on it to expand the row. By default all rows are collapsed. | false |
| subGridModel | array | This property, which describes the model of the subgrid, has an effect only if the subGrid property is set to true. It is an array in which we describe the column model for the subgrid data. The syntax is
subGridModel : [
{ name : ['name_1','name_2',...,'name_n'],
width : [width_1,width_2,...,width_n] ,
params : [param_1,...,param_n]}
]
where
|
empty array |
| subGridType | This option allow loading subgrid as a service. If not set, the datatype parameter of the parent grid is used. For example:
jQuery("#mygrid").jqGrid({
Where rowidprm is array that contains the id of the row plus other parameters as required to set subGridModel params. |
||
| subGridUrl | string | This option has effect only if subGrid option is set to true. This option points to the file from which we get the data for the subgrid. jqGrid adds the id of the row to this url as parameter. If there is a need to pass additional parameters, use the params option in subGridModel | empty string |
In these events,
| Event | Parameters | Description |
|---|---|---|
| subGridBeforeExpand | pID, id | The event is raised just before expanding the grid. When set, this event should return true or false. If it returns false the subgrid row is not expanded and the subgrid is not opened. |
| subGridRowExpanded | pID, id | This event is raised when the subgrid is enabled and is executed when the user clicks on the plus icon of the grid. Can be used to put custom data in the subgrid. |
| subGridRowColapsed | pID, id | This event is raised when the user clicks on the minus icon. The event should return true or false; when the returned value is false the row can not be collapsed. |
| Method | Parameters | Returns | Description |
|---|---|---|---|
| expandSubgridRow | rowid | jqGrid object | dynamically expand the subgrid row with the id = rowid |
| collapseSubGridRow | rowid | jqGrid object | dynamically collapse the subgrid row with the id = rowid |
| toggleSubGridRow | rowid | jqGrid object | dynamically toggle the subgrid row with the id = rowid |
| subGridJson | json, sid | jqGrid object | |
| subGridXml | xml, subid | jqGrid object |