views:

541

answers:

1

I'm having an issue with a custom ItemRenderer I've written for a DataGrid. With this ItemRenderer, it's possible that the contents could exceed the width and height of the DataGrid cell - and when this happens, scroll bars appear, letting me scroll the individual cell.

What I would like, however, is that when the contents of the cell are too large, the entire DataGrid scrolls, rather than the individual cells.

Now, when I set the custom ItemRenderer's horizontal and vertical scroll bar policies to "off", I get the vertical scrolling on the DataGrid that I want (the individual cells stretch to accommodate the full height of the contents) but I don't get any horizontal scrolling. Instead, any content too wide for the cell is clipped. Incidentally, setting the DataGrid's horizontal scroll bar policy to "on" has no effect, the scroll bar gutter is drawn, but nothing scrolls

Is there a way to force the DataGrid to scroll horizontally when my custom ItemRenderer's contents are too wide for the cell?

A: 

You may have to find a way calculate and expand the size of the DataGrid horizontally in a canvas so that it shows all the cells, and the scrollbar would appear as part of the canvas.

CookieOfFortune
I've been playing around with this, without success. The problem here is that the custom item renderer is referenced in the DataGrid as a "ClassFactory" rather than a concrete instance of some sort of UIComponent. What this means is that I don't have a way of determining the width of my item renderer at runtime, so that I can update the DataGrid's width. Any thoughts?
Dan
You might be able to grab the width of the cell though.
CookieOfFortune
Actually, try diving into the source code for the DataGrid, it does contain a reference to the ItemRenderers, but the problem is that renderers are reused, the logic behind figuring out which ones are displayed or not might be confusing though.
CookieOfFortune
I've had absolutely no luck with this. I've tried several solutions and none of them work the way I want. So far the best way I've found is to stick a Spacer underneath the DataGrid to artificially increase the width of the canvas - but it can't detect changes to column widths.I'm starting to consider reworking my design so that this scrolling behaviour is no longer necessary...
Dan