gpt4 book ai didi

java - 如何获取表或索引容器中的多个选定行?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:45:43 25 4
gpt4 key购买 nike

我有一个表,其数据源设置为 IndexedContainer。我还在我的表上启用了多项选择。问题是,我如何获取所有选定的值……也许是一个数组?

我的索引容器:

private void populateAnalyteTable () {

Analyte[] analytes = Analyte.getAnalytes();

for (Analyte analyte : analytes) {

Object id = ic_analytes.addItem();
ic_analytes.getContainerProperty(id, "ID").setValue(analyte.getId());
ic_analytes.getContainerProperty(id, "Analyte Name").setValue(analyte.getAnalyteName());

}

// Bind indexed container to table
tbl_analytes.setContainerDataSource(ic_analytes);

}

我最终想要得到的是一组 Analyte 对象

最佳答案

为什么要使用IndexContainer?为什么不使用 BeanItemCotainer?请在下面找到代码片段

table.setMultiSelect(true);
BeanItemContainer<Analyte> container = new BeanItemContainer<Analyte>(Analyte.class);
container.addAll(Arrays.asList(Analyte.getAnalytes()));
table.setContainerDatasource(container);
// Add some Properties of Analyte class that you want to be shown to user
table.setVisibleColumns(new Object[]{"ID","Analyte Name"});


//User selects Multiple Values, mind you this is an Unmodifiable Collection
Set<Analyte> selectedValues = (Set<Analyte>)table.getValue();

如果不能解决问题,请告诉我

关于java - 如何获取表或索引容器中的多个选定行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26928716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com