1

Where do I set the values that are passed to the subGridRowExpanded method. For example, I have a parent row A and I want to get the children of A so I want to pass this value to the subGridRowExpanded method.

SBel
  • 3,315
  • 6
  • 29
  • 47

2 Answers2

3

@SBel: I had the same issue these days afer upgrading to jqGrid v. 4.6.0. Oleg is - as always - right by pointing to a "wrong" id-specification. This happens sometimes when the generation of your JSON-String comes from an older jqGrid-Installation... However, these lines helped me out:

[...],
subGridRowExpanded: function(subgrid_id, row_id) {
    var rowData = $(this).getRowData(row_id);
    var uid = rowData['id'];
    [...]
}
2

subGridRowExpanded is callback function. One uses it for example to implement Subgrid as Grid. jqGrid set all parameters and then calls your callback function if you implemented it.

You should describe more clear your original problem: what you want to do and in which context (in which situation or inside of which callback).

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I've implemented subGridRowExpanded and when I expand a row it is invoked (which is what is suppossed to happen). My question is: there are 2 parameters to that function, subgrid_id and row_id, how can I use these parameter(s) to find out information that I will use to get the subgrid. For example, there are 3 top-level rows initially, identified as 'A', 'B', and 'C'. User clicks on the 3rd row, 'C'; I need to find out which row was clicked on so that I can pass the appropriate parameter to the service call, ie, service.html?id=C – SBel May 12 '12 at 15:40
  • @SBel: The second parameter is the rowid. The parameters as described in [the documentation](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:subgrid#events). So the second parameter should be 'C' in your case. So you can create new grid and use `"service.html?id="+rowid` as `url` or use `"service.html"` as `url` and `postData: {id: rowid}` as parameter. If in your case you the second parameter of `subGridRowExpanded` are initialized wrong, then you specified wrong `id` values during filling of the main grid (or didn't specified any `id` at all). – Oleg May 12 '12 at 16:04
  • The rowid parameter is null and I don't see in the documentation how to initialize the parent table. In addition, I need to pass more than 1 parameter to the service (I was just simplifying the question). – SBel May 12 '12 at 16:07
  • @SBel: First of all look at [the demo](http://www.ok-soft-gmbh.com/jqGrid/SubGrid.htm) from [the answer](http://stackoverflow.com/a/4115481/315935). If you start the demo in debugger and set breakpoint inside of `subGridRowExpanded` callback you will see that `row_id` parameter will be correctly initialized to the `id` of the row which you expand. You don't post any *your code*, so it's difficult to help you more. – Oleg May 12 '12 at 16:15
  • @SBel: Another simple example from [the answer](http://stackoverflow.com/a/10178440/315935) you can see [here](http://www.ok-soft-gmbh.com/jqGrid/LocalSubgrid.htm). I recommend you additionally to use `idPrefix` option like I described as [here](http://stackoverflow.com/a/10247633/315935). – Oleg May 12 '12 at 16:20