Vaadin Frameworkを使用してWebアプリケーションを作成していますが、テーブル要素(フィルタテーブル)があります。私のテーブルには、各行にComboBoxコンポーネントが含まれているカラムがありますが、テーブル内のコンボボックスは正しく動作しますが、そのカラムをクリックしてテーブルの値を選択することはできません。コンボボックスとカラム境界BUTは、コンボボックス自体をクリックして選択することはできません。 多くを検索したところ、https://vaadin.com/forum/#!/thread/988648/988647が黒板アドオンの実装を試みましたが、失敗しました。私のコードはおおよそ以下の通りです。Vaadinのテーブルの列の中でuiコンポーネントをクリックしてテーブル行を選択できません
PagedFilterTable<IndexedContainer> filterTable;
`public static PagedFilterTable<IndexedContainer> buildPagedFilterTable()
{
filterTable = new PagedFilterTable<IndexedContainer>();
filterTable.setFilterBarVisible(true);
filterTable.setSelectable(true);
filterTable.setImmediate(true);
filterTable.setMultiSelect(true);
filterTable.setRowHeaderMode(RowHeaderMode.INDEX);
filterTable.setColumnCollapsingAllowed(true);
filterTable.setContainerDataSource(buildContainer());
filterTable.setVisibleColumns((Object[]) new String[] {
"Clear", "Name" });
return filterTable;
}`
static int f=1;
private static Container buildContainer() {
IndexedContainer cont = new IndexedContainer();
cont.addContainerProperty("Clear", Component.class, null);// added combobox component
cont.addContainerProperty("Name", String.class, null);
//populating table with database values (table rows will be = no. of rows in db)
Connection con;
ResultSet rs;
Statement cs;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","CGoracle");
cs=con.createStatement();
co=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs = cs.executeQuery("select * from ECS_CURRENT");
while(rs.next())
{
ComboBox select_reason_return=new ComboBox();
select_reason_return.setInputPrompt("Select");
select_reason_return.setVisible(true);
select_reason_return.setNullSelectionAllowed(false);
select_reason_return.setInvalidAllowed(false);
select_reason_return.addItem("1.A/c Closed/Transfered");
select_reason_return.addItem("2.No Such A/c");
select_reason_return.addItem("3.Clear");
select_reason_return.select("3.Clear");
select_reason_return.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
String reason=select_reason_return.getValue().toString();
rowId=FilterTable.getValue();
Notification.show("row id is ="+rowId);
}
});
cont.addItem(f);
cont.getContainerProperty(f, "Clear").setValue(select_reason_return);
cont.getContainerProperty(f, "Name").setValue(rs.getString(10));
f++;
}
}
catch (SQLException | ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return cont;
}
If it helps, I'm posting screenshots, Image 1: if I select anywhere other than the combobox, it is returning row id properly.Image 2: Though I'm selecting an item from combobox, table row is not getting seleced, hence it's not returning me row id. 黒板アドオン以外のオプションはありますか?いいえ、私はそれでこの問題を解決するために手伝ってください。
私は上記のコードであなたの提案されたメソッドを実装しましたが、私は行IDをnullに戻しています。同じスクリーンショットを添付しました。 – Ahmey