skip to Main Content

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?

2

Answers


  1. Chosen as BEST ANSWER

    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


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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search