2016-08-14 28 views
3

我们在我们的网站(Vaadin Table)中使用了很多表格,但是我们的客户告诉我们他们希望能够在表格内进行编辑。现在,我知道这是可能的表(我已经得到这个工作),但我有点像编辑机制更好的网格。有没有简单的方法将Vaadin Table转换成Vaadin Grid?由于Grid不是替代品,我知道它需要一些转换工作。只是想知道人们有多难找到它,以及是否有任何文件在做这样的转换。将Vaadin Table转换为Vaadin Grid

这是我们正常的表的使用情况:

public final class ReplenishmentOrderMgmtView extends VerticalLayout implements View { 

    private final Table table; 
    private static final String[] DEFAULT_COLLAPSIBLE = { 
    "contactFirstName", 
    "contactLastName", 
    "supplierName", 
    "carrier", "carrierService", "trackingNumber" 
    }; 
    private static final Object[] VISIBLE_COLUMNS = { 
    "barcode", 
    "contactUserId", 
    "contactFirstName", 
    "contactLastName", 
    "PO", 
    "orderId", 
    "cellId", 
    "cellName", 
    "wmsItem", 
    "description", 
    "supplierId", 
    "supplierName", 
    "statusDesc", 
    "resizedBinQty", 
    "expectedOnDockDate", 
    "shipQuantity", 
    "receivedQty", 
    "lastReceiptDate", 
    "carrier", 
    "carrierService", 
    "trackingNumber", 
    "creationDate" 
    }; 
    private static final String[] COLUMN_NAMES = { 
    "Barcode", 
    "Contact User", 
    "First Name", 
    "Last Name", 
    "PO Number", 
    "Replenishment Order Id", 
    "Cell Id", 
    "Cell Name", 
    "Part", 
    "Description", 
    "Supplier Id", 
    "Supplier Name", 
    "Status", 
    "Resized Bin Qty", 
    "Expected On Dock Date", 
    "Ship Quantity", 
    "Received Qty", 
    "Last Receipt Date", 
    "Carrier", 
    "Carrier Service", 
    "Tracking Number", 
    "Creation Date" 
    }; 


    private Table buildTable() { 
     final Table table = new Table(); 
     table.setSizeFull(); 
     table.addStyleName(ValoTheme.TABLE_BORDERLESS); 
     table.addStyleName(ValoTheme.TABLE_NO_HORIZONTAL_LINES); 
     table.addStyleName(ValoTheme.TABLE_COMPACT); 
     table.setSelectable(true); 

     table.setColumnCollapsingAllowed(true); 

     table.setColumnReorderingAllowed(true); 

     updateList(table); 

     table.setSortContainerPropertyId("creationDate"); 
     table.setSortAscending(true); 

     table.setColumnHeaders(COLUMN_NAMES); 

     // Allow dragging items to the reports menu 
//  table.setDragMode(TableDragMode.MULTIROW); 
     table.setMultiSelect(false); 

     table.addActionHandler(new ReplenishmentOrdersActionHandler()); 

     table.addValueChangeListener(event -> this.selectItemFromTable()); 

     table.setImmediate(true); 

     return table; 
    } 
} 

也有一些有约束力的参与在那里 - 我的数据源是一个Java bean。显然,我只包含会影响表本身的代码。任何意见或意见将不胜感激。

回答

1

有没有简单的方法将Vaadin Table转换为Vaadin Grid?

您必须声明和应用网格,并没有直接的方法的性能有电网和表之间的转换。两者都是不同的元素,不能与所谓的以UI方式进行最小变化切换。

由于交换涉及到很多事情要考虑的一样,

  • 表中的数据源可以正常工作与网格。适用于表
  • 风格不会为网格工作(即 Valo的主题风格,响应风格)表的
  • 事件不一样的网格。表具有值更改事件,而网格具有项目点击侦听器。
  • 等等...

但是,你可以有两个要素相同的容器。容器数据源可以在两个元素之间通用。请注意,Grid有一些限制,例如它不支持行中的组件,而表格则支持该组件。另一方面,网格是快速的,优化了一些额外的功能,如冻结柱,支持组件在头等。相同的方式表是后代网格,并没有一些功能支持网格。