DataGrid什么也没显示

时间:2019-02-11 19:18:45

标签: gwt

我正在将DataGrid添加到FlexTable中的SimpleLayoutPanel中。我无法显示任何数据,甚至无法显示标题。每当我在DataGrid中调用setHeight()之类的方法时,我的整个FlexTable都会消失,并且我会有空白页。

我尝试了不带SimpleLayoutPanel的DataGrid(在我的代码中为userPanel),没有任何区别。我已经使用CellTable和ScrollPanel进行了尝试,并获得了相同的结果。

Paragraph.Range

数据从演示者加载到此方法中

public AdminViewImpl() {

    SimpleLayoutPanel contentPanel = new SimpleLayoutPanel();
    initWidget(contentPanel);
    contentPanel.setWidth("100%");
    contentPanel.setHeight("100%");

    final FlexTable adminTable = new FlexTable();
   FlexTable.FlexCellFormatter cellFormatter = adminTable.getFlexCellFormatter();
    adminTable.addStyleName("flexTable");
    adminTable.setWidth("99%");
    adminTable.setCellSpacing(5);
    adminTable.setCellPadding(3);

    cellFormatter.setHorizontalAlignment(0,0,HasHorizontalAlignment.ALIGN_CENTER);
    cellFormatter.setColSpan(0,1,2);
    adminTable.setHTML(0,0,"<h1> GRAPL AUTOMATION</h1>");
    contentPanel.add(adminTable);

    VerticalPanel buttonPanel = new VerticalPanel();

    buttonPanel.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    cellFormatter.setVerticalAlignment(0,1,HasVerticalAlignment.ALIGN_MIDDLE);
    cellFormatter.setHorizontalAlignment(0,1,HasHorizontalAlignment.ALIGN_CENTER);
      addButton = new Button("Add User");

    addButton.setStyleName("addButton");
    buttonPanel.add(addButton);


    adminTable.setWidget(0,1,buttonPanel);


    userPanel = new SimpleLayoutPanel();
    userPanel.setSize("1000px","200px");
    userPanel.getElement().getStyle().setBorderStyle(Style.BorderStyle.SOLID);
    cellFormatter.setVerticalAlignment(1,0,HasVerticalAlignment.ALIGN_MIDDLE);
    cellFormatter.setHorizontalAlignment(1,0,HasHorizontalAlignment.ALIGN_CENTER);
    cellFormatter.setColSpan(1,0,3);
    cellFormatter.setHeight(1,0,"200px");
    //userTable.setHeight("10px");
    //userTable.setAutoHeaderRefreshDisabled(true);
    // Set the message to display when the table is empty.
   // userTable.setEmptyTableWidget(new Label("Grid has no Data"));
    userPanel.add(userTable);


    adminTable.setWidget(1,0,userPanel);
   //userTable.redraw();
}

1 个答案:

答案 0 :(得分:0)

我的错是实例化了2个DataGrid。

相关问题