Hi,
In our application we have search fields, following the pattern of Google’s “instant” search : you start typing in a textfield, and after a period of inactivity, the search results popup below the search field.
In Vaadin 6, we used the Overlays add-on to display the search results (in an Table of undefined size) relative to the textfield.
In Vaadin 7, the Overlays component is not available. The comparable V7 add-on is Henrik’s PopupExtension - but (probably due to an implementation “hack” whereby the table isn’t attached to the DOM until late), the sizing of the columns of the table is all wrong. I had a look, but it seems quite tricky to fix (I think it’s due to the “natural” sizing of the columns occuring very early on, before the component is displayed : see
this discussion
for more details.
So, I’ve started working on a component heavily based on PopupView (for which read copied and modified not extended, due to private methods/variables on the client side) that will allow us to popup a component relative to any other component already displayed. (Sounds very like the Overlays component to me!)
It’s beginning to work quite nicely - however, I am coming across an issue with the sizing of the table (when table’s size is undefined), which then affects the sizing/positioning of the popup.
The same behaviour is exhibited by the standard PopupView.
If the “large” - i.e. component to be popped up - is a table of undefined size, the size reported by VPopupView#center() by popup#getOffsetWidth() & popup#getOffsetHeight() is not the same as the sizes reported by Web Inspectors in Chrome/FF - which then means that the component is not actually centered over the small/view component. For what it’s worth, I’m actually not that worried about the centering, but more the adjustment to ensure that the popup component appears on the screen (e.g. if left+width > windowRight, left = left-width and similarly for top/height) - but both will be affected by the same issue.
For illustration, In my example code the offsetWidth/offsetHeight of the popup containing the table (that is, the v-popupview-popup) is 291x344 in the Web Inspector/Firebug, yet in the VPopupView#center method it is reported as 221x364
I really want to avoid explicitly sizing the table, if I can possibly help it - I’d like it to take as much room as needed to show all of the columns at their natural width, and the given pageLength number of rows + header + footer. (Where possible, we want to avoid setting sizes on components)
Any idea of what is going on here? Is what I am trying to do possible?
Cheers,
Charles.