简体   繁体   English

如何将DataGrid窗口小部件添加到Gwt中的列表框

[英]How to add DataGrid Widget into Listbox In Gwt

I want to create listbox.and when user clicks on that i want to display datagrid into dropdown. 我想创建列表框。当用户单击该框时,我想在下拉列表中显示数据网格。 private DataGrid objDataGrid; 私有DataGrid objDataGrid;

public CallDataGrid() {
    // TODO Auto-generated constructor stub
}
public CallDataGrid(ArrayList<Student> objArrayList) {

    System.out.println("Datagrid is now going to set.");
    objDataGrid = new DataGrid<Student>();
    objLayoutPanel = new SimpleLayoutPanel();
    objScrollPanel = new ScrollPanel();

    objScrollPanel.add(objDataGrid);
    objLayoutPanel.add(objScrollPanel);

    objDataGrid.setEmptyTableWidget(new Label("There is no data to display."));

    final TextColumn<Student> nameColumn = new TextColumn<Student>() {
                         @Override
                         public String getValue(Student object) {
                                return object.getStrName();
                         }
    };
    objDataGrid.addColumn(nameColumn, "User Name");
    objDataGrid.setColumnWidth(nameColumn,100,Unit.PX);

    final TextColumn<Student> passwordColumn = new TextColumn<Student>() {
             @Override
             public String getValue(Student object) {
                return object.getStrPassword();
             }
      };
     objDataGrid.addColumn(passwordColumn, "Password");
     objDataGrid.setColumnWidth(passwordColumn,90,Unit.PX);

     objDataGrid.setWidth("190px");
     objDataGrid.setHeight("100px");

     objDataGrid.setRowData(0, objArrayList);
     objDataGrid.setPageSize(5);

// now how can i set this datagrid into Listbox or suggestion box?? //现在如何将这个数据网格设置到列表框或建议框中?

No direct way to do what you want. 没有直接的方法去做你想要的。 Instead of a ListBox widget you can use a TextBox with a button on the right. 可以使用带有右侧按钮的TextBox代替ListBox小部件。 When clicking the button put your DataGrid into a PopupPanel and display it by setting the its position on the bottom of the TextBox. 单击按钮时,将您的DataGrid放入PopupPanel并通过在TextBox底部设置其位置来显示它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM