Complex layout for Grid

Is it possible to layout a record in the Grid with something like colspan and rowspan logic? The idea is that I have two rows per record, laid out like:

-------------------------------------------------------------------------
|  ID      |  Title                           |   Start Date  |  Status |
-------------------------------------------------------------------------
| Long Description                                                      |
-------------------------------------------------------------------------

or alternatively

-------------------------------------------------------------------------
|  ID      |   Start Date  |  Status |  Long Detail                     |                                                     
-------------------------------------|                                  |
|   Title                            |                                  | 
-------------------------------------------------------------------------

Hi tgochenour,
Yes you can achieve both of these presentations, with a little tweaking:

We have a property (unexposed in 5.5.1) on records: record.singleCellValue.
This should be set to a string of HTML, and if set, the record in question’s row will be a single cell that spans every column in the be displayed for the row.
This means you can get the first presentation by doubling up your records in the data-set, and for the second record, setting ‘singleCellValue’ to the long description for the record.
A couple of notes:

  • You may end up with some strange sorting behavior in with this approach. The duplicate records (with and without the singleCellValue) should stay adjacent to each other regardless of which field is sorted by but you may see the description appearing above the other row in some cases. If you need full, predictable sorting behavior, let us know and we can get into how to make that work

  • By default users will be able to select either of the 2 rows, even though they essentially represent the same record.
    A couple of options for this - possibly using the selectionChanged notification to catch the user selecting rows, and programatically respond by ensuring the associated row is also selected.
    On a related note you’ll get separate rollOver styling for each of the rows, which may not be what you want - again there are ways to workaround this, the easiest of which is of course to disable rollover styling altogether via ListGrid.showRollOver. If you need a better solution for this let us know and we can show you a couple more options.

To achieve the second example, we would suggest you achieve this with a 2 column grid, and explicitly writing out HTML for a table in the first column via an override to formatCellValue().
You’d want to change the specified cellHeight for the grid, probably the wrapCells property, and possibly override fixedRecordHeights to allow rows to expand to fit their content.

We don’t support a generalized rowSpan / colSpan for cells at the moment as it would introduce a great deal of complexity in various areas (incremental rendering code, selection, event handling, inline editing, etc).
It is an area that we’ll be adding more support to in the future, in limited use cases.

How is my data supposed to know how it should be rendered? You want me to add this property to my model when I receive it and then strip it from the serialization as it goes back to the server? This violates “separation of concern” in a Model/View/Controller design pattern.

Yet in principle I like the idea of a single HTML cell rendering the contents of the entire record rather than enumerating the fields as is done by default. I need to find a way to configure the <ListGrid> to use a custom record renderer without hacking my model. Something analogous to field.formatCellValue(), perhaps grid.formatRecordLayout().

Hi tgochenour,

What we’d suggest is a custom component that transparently adds extra records to achieve the desired presentation. This doesn’t violate MVC, however, you’ll be using the ListGrid as more of a low-level renderer. A number of overrides will be required to achieve normal grid functionality (as previously outlined).

Your other option is to contact Isomorphic about getting new APIs added in connection with a license.

Hi,

as I have seen, the last post on this thread is 3 years old. What is the best way today.

As you can see in the attached image, i have spletted rows and collums.

bye