Can't make columns resizable after adding header rows #234
Comments
Hello Pekka, It's working with header rows. Thanks |
Hi @DabhiGhanshyam ! |
Hello Pekka, Thanks for your quick response. The error TypeError: Cannot read property 'offsetWidth' of undefined. occurs when I try to drag the first header row for top-right corner as attached in screen-shot. When I tried to drag that blue bar (dragging left side) at that time it throws error. Please find code below: `Column averagePriceColumn = vaadinGrid.addColumn(PriceData::AvgPrice).setHeader("Average Price"); HeaderRow gridFilterRow = vaadinGrid.appendHeaderRow(); Column maxPriceColumn = vaadinGrid.addColumn(PriceData::MaxPrice).setHeader("Max Price"); Span spnHeader = new Span("Price"); vaadinGrid.prependHeaderRow(); vaadinGrid.getColumns().forEach(column -> { vaadinGrid.getColumns().forEach(column -> { Thanks once again. |
Ok, I found the issue which is actually a bug in the While playing around with the client-side web component I also found out that you don't actually need to set the Anyway, if you set column.getElement().callFunction("setAttribute", "resizable", true); ( Also, if you have eg. two columns, it's enough to set that for only the first column. If you set it for both, you'll get that drag-handle on the right end of the headers which doesn't make much sense. I'll update the issue description to mention this simpler and less buggy workaround. EDIT: Here's proof of the bug you found with just the web component: EDIT2: Here's the issue for the web component: vaadin/vaadin-grid#1480 |
Hello Pekka, Hurray !!! Astonished !!! It works perfectly. Thank you very much for your great help. |
Hello, Apologies in advance if I had overlooked something. Code to re-create
|
Hi @ttsanton! column.getElement().getParent().callFunction("setAttribute", "resizable", true); |
Hi @pekam, I tried these ways:
And also
|
Sorry! I forgot to mention one important point: This needs to be done after appending the header row. |
Got it! Thank you @pekam!!! |
I have an Iterable list. like: |
Hi @KamrulHasan-Seu! Please ask this kind of questions next time in the Vaadin forum. This page should be reserved for discussing the particular issue described in the original post. If your repository's return type is Iterable<T> items = modelRepo.findAll();
List<T> list = new ArrayList<>();
items.forEach(list::add);
grid.setItems(list); |
I think the main issue here is basically a duplicate of vaadin/vaadin-grid#1577 (which was just fixed in master). With the master version of the web component just setting resizable on the initial column should "work" so that you will have a working resize handle but due to the way the Java API works you would only get the resize handle on the bottom most header row. I guess it might make sense to keep this issue still open for improving what the Java API does to manage the resizable for all layers of headers? Or should we open a new clean issue about that and close this one? |
I'd consider this issue fixed if the resize-handles are working on the bottom headers after your fix. It's a different question whether |
Closing this as a duplicate of vaadin/vaadin-grid#1577 which has been fixed in |
UPDATE:
The description below seems to be incorrect. You don't need to set
resizable
for all the parent elements to make a column resizable. But for some reason the property/attribute doesn't seem to get updated otherwise.Setting
resizable
with javascript after the grid is rendered seems to work, so as a workaround, you can use:Below is the old description which seems to be incorrect.
Calling
column.setResizable(true)
correctly sets the property for the<vaadin-grid-column>
.The problem is that the web component expects all the parent
<vaadin-grid-column-groups>
to have theresizable
property also, or otherwise the column can't be resized. Currently we don't have a component-level API for accessing the column groups, since they are hidden behind theHeaderCell/FooterCell
APIs.One possible fix is to make sure that the parent column-groups of a resizable column always have this property also, so that the user doesn't even need to set it for the parent groups manually.
Here's a workaround which should work only after all the headers and footers are added:
The text was updated successfully, but these errors were encountered: