0

Vaadin version : 23.3.1

I am trying to display the fetched JSON data in grid, It is ignoring the new line in the data.

I have bunch of JSON data which I am adding to a list and will add to the grid later

class Details{

 String message;
 Details(String msg){
   this.message = msg;
 }
 public String getMessage() {
        return msg;
 }

 public void setMessage(String msg) {
        this.msg = msg;
 }

}

Where Details is class which contains variable of type String message.

public static List<Details> details  = new ArrayList<Details>();
Details items =  new Details(JSON_values); 
details.add(items);

Creating list of objects of type detail class and writing it with JSON_value and then adding it to a list and after binding displaying it in grid.

After that I am adding it to the grid along with other columns

  grid.addColumn(Details::getMessage).setHeader("MESSAGE");
  grid.getColumns().forEach( col -> col.setAutoWidth(true));
  grid.setItems(details);

Where details is another list of all the parameters.

I am trying to use the Html component but failed to do so.

Any suggestions on how to proceed further?

Harry
  • 1
  • 2

2 Answers2

0

You can use grid.addThemeVariants(GridVariant.LUMO_WRAP_CELL_CONTENT); to make the cell contents increase in size.

ollitietavainen
  • 3,900
  • 13
  • 30
  • Its not about increasing the cell content in size, Its about giving the line breaks wherever present in the data. – Harry Jan 23 '23 at 06:38
  • For the line breaks using newline characters, you probably just want something like https://stackoverflow.com/a/2703609/3608089 – ollitietavainen Jan 23 '23 at 11:27
-1

I used TextArea Component in the Vaadin Grid which will display the formatted data as it is without truncating the new lines or whitespaces.

Using the Component Render method

https://vaadin.com/docs/latest/components/grid

Harry
  • 1
  • 2