2
A
回答
2
问题的标题不能反映内部
有只选择行的单元格的任何方式的实际问题?
号一个Vaadin表的整点是反映行以表格形式数据的。表设置为可选跟踪选定行的itemIds与表
您可能能够由表中使用ColumnGenerator
,并添加监听到生成组件模拟选择单元格。然而,移除监听器可能会很棘手。
或者,您可能希望简单地生成GridLayout
中的组件并自行跟踪所选单元格。
最终,这里的方法实际上取决于你想要达到的目标。
1
这取决于你想要完成什么。 (您的问题标题和您的问题细节解决了两个不同的问题。)如果您想知道您是否可以定位特定单元格并为其添加点击监听器,那么当然可以:
//initial layout setup
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
//Create a table and add a style to allow setting the row height in theme.
final Table table = new Table();
table.addStyleName("components-inside");
//Define the names and data types of columns.
//The "default value" parameter is meaningless here.
table.addContainerProperty("Sum", Label.class, null);
table.addContainerProperty("Is Transferred", CheckBox.class, null);
table.addContainerProperty("Comments", TextField.class, null);
table.addContainerProperty("Details", Button.class, null);
//Add a few items in the table.
for (int i=0; i<100; i++) {
// Create the fields for the current table row
Label sumField = new Label(String.format(
"Sum is <b>$%04.2f</b><br/><i>(VAT incl.)</i>",
new Object[] {new Double(Math.random()*1000)}),
Label.CONTENT_XHTML);
CheckBox transferredField = new CheckBox("is transferred");
//Multiline text field. This required modifying the
//height of the table row.
TextField commentsField = new TextField();
//commentsField.setRows(3);
//The Table item identifier for the row.
Integer itemId = new Integer(i);
//Create a button and handle its click. A Button does not
//know the item it is contained in, so we have to store the
//item ID as user-defined data.
Button detailsField = new Button("show details");
detailsField.setData(itemId);
detailsField.addListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
// Get the item identifier from the user-defined data.
Integer iid = (Integer)event.getButton().getData();
Notification.show("Link " +
iid.intValue() + " clicked.");
}
});
detailsField.addStyleName("link");
//Create the table row.
table.addItem(new Object[] {sumField, transferredField,
commentsField, detailsField},
itemId);
}
//Show just three rows because they are so high.
table.setPageLength(3);
layout.addComponent(table);
检查the documentation可能是有益的。
相关问题
- 1. 如何使vaadin表单元格单击监听器
- 2. 如何将点击监听器添加到GWT中的InputElement?
- 3. 如何将GWT点击监听器添加到图像?
- 4. 如何在单元格中添加包含可点击的SPAN的表格
- 5. 如何添加ItemSorter到Vaadin中的表格容器?
- 6. 如何将点击监听添加到充气的XML按钮?
- 7. 如何将鼠标监听器添加到自定义JTable标头单元格渲染器中的组件
- 8. 将点击监听器添加到gwt的Grid行
- 9. 如何将Widget作为单元格添加到单元格表中GWT
- 10. 如何在IONIC2中添加标记点击监听器?
- 11. 添加点击监听器覆盖类
- 12. 如何将点击事件添加到javafx中的tableview单元格
- 13. 如何将NSTableView单元格添加到单元格的填充?
- 14. 如何添加点击监听器到自定义relativeLayout
- 15. 如何添加点击监听器到谷歌地图道路?
- 16. Ext JS 4.1:将点击事件监听器添加到headerCheckbox
- 17. AJAX将表添加到表单元格
- 18. 将图像添加到部分中的表格单元格
- 19. 将单元格添加到VBA中的表格
- 20. JTable单元格值更改监听器
- 21. 如何将UISwitch添加到分组表格视图中的单元格中?
- 22. 如何添加双击监听器到primefaces数据表
- 23. 如何添加延迟到网格面板中的单元格单击事件
- 24. 使用jQuery将单元格添加到基于href的另一个单元格中的表格单元格
- 25. 如何为vaadin表格的项目或单元格添加工具提示
- 26. jquery点击监听器只在表格的第一行工作
- 27. 添加事件监听器到网格中的一类XTemplate元素
- 28. 如何添加布局到vaadin中的表格组件?
- 29. 如何将UITapGestureRecognizer添加到表格视图单元格内的UILabel中?
- 30. 如何将按钮添加到表格视图中的单元格
谢谢你的回答。我搜索ColumnGenerator并编写了代码,但它不起作用。我试图做一个表(7X24),当我点击一个单元格时,该行中的其他单元格将不会被选中。如果你能给我一个简短的例子,我会很高兴。 – Hasan 2012-07-23 13:17:30
@Hasan:你有没有试过让表setSelectable(false)? – 2012-07-23 13:32:57
不,我没有。代码在这里http://www.manashk.com/java/。程序只创建表并不加载内容。 – Hasan 2012-07-23 13:55:31