I am not sure if a datagrid can be used as detail of another datagrid. I have used the following mechanism and it looks it runs for ages without any result! Is it the right approach?
public void initDetailGenerator() {
productionPlanDataGrid.setDetailsGenerator(new DataGrid.DetailsGenerator<ProductionPlan>() {
@Nullable
@Override
public Component getDetails(ProductionPlan entity) {
VBoxLayout mainLayout = componentsFactory.createComponent(VBoxLayout.class);
mainLayout.setWidth("100%");
mainLayout.setMargin(true);
HBoxLayout headerBox = componentsFactory.createComponent(HBoxLayout.class);
headerBox.setWidth("100%");
Label infoLabel = componentsFactory.createComponent(Label.class);
infoLabel.setHtmlEnabled(true);
infoLabel.setStyleName("h1");
infoLabel.setValue("Order info:");
DataGrid<PlanOrderOperations> detailGrid = componentsFactory.createComponent(DataGrid.class);
planOrderOperationsesDs.setQuery("select e from erp$PlanOrderOperations e where e.operation.id = :custom$opsId");
planOrderOperationsesDs.refresh(ParamsMap.of("opsId", entity.getOperation().getId()));
detailGrid.setDatasource(planOrderOperationsesDs);
headerBox.add(infoLabel);
mainLayout.add(headerBox);
mainLayout.add(detailGrid);
return mainLayout;
}
});
}
The table for this case should have 9 columns, what is displayed looks like a label brokenly constructed from a table
I think this is why in the documentation, the detail is created as an html Label or I suppose so, because the code of getContentLabel is not provided, as well as the code for createCloseButton.
Hi Gleb
That’s great!
I looked at the sampler, it’s still old sampler. Is there any sampler available around where a datagrid is used as detail of a datagrid?