adding sub property to grid

How can we use the property from another class inside the class we are using in the grid ?

grid.addColumn(“parentCompanyId.id”).setHeader(“Parent Company”).setAutoWidth(true).setSortable(true);

@Entity
@Table(name = “Company”)
public class Company {
@Id
@Column(name = “company_id”, nullable = false)
private Integer id;

@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "parent_company_id")
private Company  parentCompanyId;

}

How do you mean that,?

I want to use the id from parentcompanyid object.

That’s no problem. Just use the addColumn method with the ValueProvider:

grid.addColumn(c-> c.partneCompanId.id)

how to handle null value for parentCompanyId ?

Simply add an if in the lambda

grid.addColumn(c-> {
if (c.partnerCompanyId != null) {
   return c.partneCompanId.id);
} else {
  return "";
}
}