user590586
user590586

Reputation: 3050

jqgrid hidden subgrid

I want to create a subgrid for each row inside my grid , and that the subgrid will be hidden , so the user will not know it is there - i use it to save diffrent data for each row.

so how can i add a hidden subgrid to each row? and how do i add rows to it?

Thank's In Advance.

Upvotes: 1

Views: 673

Answers (1)

Oleg
Oleg

Reputation: 221997

If you need associate any additional information with the grid or with any row of the grid you can do this in other ways as with hidden subgrid. You don't described more exactly whether you use local grid or the datatype 'json' or 'xml'. I suppose, that you get data from the server and use datatype 'json' or 'xml'. Here are some standard options which you can use

1) You can define some addtitional hidden columns in the grid. (see hidden:true column property). You can access the data using getCell or getRowData methods.

2) You can use userdata with any data which has absolutely free format. If the data will be have the following format (it is an example only)

{
    "id1":{/*any data object what you want associate with the row having id="id1"*/},
    "id2":{/*any data object what you want associate with the row having id="id2"*/},
    ...
    "idN":{/*any data object what you want associate with the row having id="idN"*/}
}

then you can any time get the userdata with

var myUserData = jQuery("#grid_id").getGridParam('userData');

and with the structure of the userdata described above you can access row specific data just as myUserData[rowid] (like myUserData["id2"]).

3) if you post from the server back more data as the grid columns need you can access the data inside of loadComplete: function(data) through the data parameter. You can save the additional data in any other place. For example you can use jQuery.data to associate (to save) any data to the grid row (to every <tr> element).

Upvotes: 3

Related Questions