View Full Version : Extended grids

26 Nov 2009, 1:11 PM
Hi all,

We use many grids to show customer's data in our application. And GXT grid control proved to be very useful and handy.

But there are some cases when the way it's being rendered should be changed.

Image grid_0.png shows a normal grid:

But sometimes it should be shown like on image grid_1.png:

Or even like on grid_2.png:

In other words cells of one row can be folded into several subrows.

In order to support this a customized GridView is created. It overrides GridView behavior when
- column headers are rendered (only columns of first subrow should be shown)
- grid total width is calculated (some column headers should not be shown)
- row is rendered into html (more than one tr-elements should be created)
- Javascript Element object is determined (cause number of tr-elements has been changed, otherwise onClick will work correctly for first subrow only)

At the moment this approach is implemented as a patch for GXT 2.0.4 (see attached archive).
Besides CustomGridView it contains slighly patched ColumnHeader class (just a method getColumnCount() is added so that it can be overrided by CustomGridView).

CustomGridView has two properties:
- int[] subrowLength (array of subrow lengths)
- int[][] colSpan (some columns can be extended to 2 and more subrows)

So for use cases shown above one should type:

- grid_1.png
result.setView(new CustomGridView(new int[]{3, 2}, new int[][]{{0,2}}));
(first subrow consist of 3 columns, the second subrow consists of 2 columns, first column occupies 2 subrows)

- grid_2.png
result.setView(new CustomGridView(new int[]{4, 1}, new int[][]{{0,2}, {2,2}, {3,2}}));

For sure API is not perfect and array things can be changed to whatever else.

I guess that more people than me and my colleagues need such folded grids.

So could you please consider if they can be included into next GXT release. TIA

10 Dec 2009, 8:05 AM
my 2 cents:

1) the definition is very confusing on the first time ... it should be more easy more easy to define the rowlayout. the verb colspan means in html a different thing.
2) patching the columnheader is not a good idea. better make the CustomGridview in that way that it can be easy drop in whithout patching existing classes.