How to set Row height dynamically in vaadin 7 Grid? - vaadin

I'm creating a vaadin grid with three columns of which one column is having HTML contents. HTML data can be in multiple lines. By default only first line of HTML Data is getting displayed in the Grid.
Below is my code
Grid grid = new Grid();
grid.setColumns("C1","C2","C3");
grid.getColumn("C1").setHeaderCaption("Column 1");
grid.getColumn("C2").setHeaderCaption("Column 2");
grid.getColumn("C3").setHeaderCaption("Column 3");
grid.getColumn("C2").setRenderer(new HtmlRenderer());
grid.addRow("text1","<p>Line 1 Data</p><p>Line 2 Data</p>","data1");
grid.addRow("text2","<table><tr><th>Month</th><th>Savings</th></tr><tr><td>January</td><td>$100</td></tr></table>","data2");
And the grid looks like this
How to set the height of rows dynamically based on height of the HTML Data?
I'm using vaadin 7

How to set the height of rows dynamically based on height of the HTML Data?
This feature is not supported in Vaadin 7 or Vaadin 8 Grid. The Grid is based on fixed height rows. In Vaadin 7 you can set the Grid height in your theme (see more info here: https://vaadin.com/forum/thread/14385724), in Vaadin 8.1+ there is also setRowHeight() method in Grid.

Related

Adjusting Vaadin grid height

I am trying to add multiple Vaadin grids of different sizes inside a VerticalLayout container.
public class Overview extends VerticalLayout {
Grid<DataTable1> grid1 = new Grid<>();
Grid<DataTable12> grid2 = new Grid<>();
Grid<DataTable13> grid3 = new Grid<>();
}
So far, each grid is taking up an equal amount of vertical space, as shown in the image below.
grids taking equal vertical space
However, I would like to show the grid as shown in the image below where the height gets dynamically adjusted as per the number of rows and cloumns:
desired grids
Is there any way I can adjust the individual grid height?
So far I have found a way to adjust the row height not the height of the whole grid itself.
Thank you!
Sounds like you might be looking to achieve dynamic height based on the number of rows, which can be done using setAllRowsVisible(true): https://vaadin.com/docs/latest/components/grid/#dynamic-height
The Grid, like all components that implement HasSize, has a method setHeight()

Ag-grid cell issue (on showing paragraph content )

Let suppose I have content in one column of ag-grid more than the width so it's coming in next line, but I need to restrict that and show ellipsis if content is more than 2 line

Vaadin 8 grid row height is not automatically adjusting

I am working on the grid component in vaadin 8. In My grid, each column data fetched from the database and it may be too lengthy. the grid row height is not expanding based on the content in each column. My grid is given below.
You can see complete content is not visible in each columns.
In Vaadin8 the Grid component rows are not auto-adjusting, i.e. this feature does not exists there. The Grid rows are of fixed height. There is an API to configure the row height e.g. grid.setRowHeight(50).
This limitation no longer exists in the newer generation Vaadin frameworks, e.g. Vaadin 14.

Vaadin Grid autoheight for cell

in my Grid a have a cell with long text .
Automatically Grid makes width:auto and I get very wide cells.
I want to make this cells more "readable" for user with
.dashboard .v-grid-cell{
word-wrap:all;
height:auto;
}
It takes no result ((
And I don't want to make all rows with same height, height or each row must be dependable of height of this cell.
You hope my question is clean ))
Grid in Vaadin 8 and Vaadin 7 does not support rows being of variable heights. So unfortunately answer is no.
In latest versions of Vaadin Platform 10 and newer there is totally new implementation of Grid, which however supports variable row heights.

How to auto-size a DevExpress TcxGrid

I've created a table from a TcxGrid with a simple table view. The data is being poked into the table using DataController.Values[n,m] as a simple string and I have some 10 columns that will show various string widths.
The problem that I'm having is getting a table that has a horizontal scroll bar AND has auto-sized its columns. If I set CellAutoWidth true this fits all columns into the display width (with no scroll bar) but if I set it false, I get a scroll bar but columns of my default width and my data strings are truncated.
Could some kind person tell me how to get a horizontal scroll bar AND get each column to adjust its width to fit its max data width please?
Thanks
Brian.
Maybe it's enough to call YourGridView.ApplyBestFit instead of using CellAutoWidth.
You need to set columns BestFitMaxWidth and MinWidth property and make sure you have the width of the Datasets TField also set (if you are using DataSets).
Then, you can call YourGridView.ApplyBestFit;

Resources