2

I need to populate my subgrid which shows some of the columns from main grid without actually going and getting data again using URL? Example:Main Grid is getting data from server (10 columns) using jsonReader. Out of which I want to show 7 columns in the parent row and 3 columns in the subgrid row . Can I do this? (Or some other way to achieve this expand concept?)

user1407415
  • 109
  • 1
  • 8
  • The requirements seems strange for me. In the case you will have always subgrid with one row only. Isn't it so? Moreover if you already *shows* the subgrid data in additional columns why you need to display the same information one more time? Probably you want to have grid with subgrid like in described in [the question](http://stackoverflow.com/q/14194754/315935)? – Oleg Jan 07 '13 at 14:33
  • Hi Oleg, actually this requirement isn't strange at all. In fact I was thinking about the same thing. Suppose we have 20 fields in a record which we can't fit in the page in one long row without scrolling. Then we would want to split up the less important columns and move them to the "subgrid". That way the most important information remains visible in the main row while the other fields are still close. The advantage is that we can layout the other 13 fields much better like a form, instead of like a row. I think this use case is important enough that it should be officially supported. – Amit Naidu May 07 '13 at 03:06

1 Answers1

0

One possible workaround to use the sub-grid as 1-1 with main grid, instead of as parent-child : query all the columns as normal in the parent grid, but set the ones you don't want in main row as hidden. Then in sub-grid load event, access those fields using the "parent" row id and create them as custom fields or simply emit custom html. This does cause duplication of the fields though, since the original main grid fields are still present, even if hidden. The html ids will get duplicated and may cause conflicts if you don't handle them.

Perhaps there is a cleaner way to do it than this (which I'm sure @Oleg will show us any minute now!) But I wish jqgrid had a documented feature to more easily handle this kind of thing. It is very useful because you get the benefit of full inline editing in the subgrid, so you can design a much nicer edit form (eg. multiline textareas) than when confined to one straight line.

Note the presence of this feature in other grids.

Jquery EasyUI Datagrid demo

Telerik Grid Editing Demo

Amit Naidu
  • 2,494
  • 2
  • 24
  • 32