0
테이블 뷰에 열 수가있는 경우 첫 번째 열에 onEditCommit 메서드를 설정하여 값을 삽입 한 다음 해당 값을 기준으로 데이터베이스에서 데이터를 검색하고 설정합니다. 다른 열의 검색된 데이터 테이블에서 내용을 업데이트 할 수 없습니다. 새 행을 추가 할 때 javaFX 테이블 뷰가 테이블 크래시를 업데이트 할 수 없음
accountNoCol.setOnEditCommit(new EventHandler<CellEditEvent<Bond, String>>() {
@Override
public void handle(CellEditEvent<Bond, String> event) {
String newValue = event.getNewValue();
Bond bond = event.getRowValue();
int selectedRow = event.getTablePosition().getRow();
if (isInteger(newValue)) {
((Bond) event.getTableView().getItems().get(
event.getTablePosition().getRow())).setAccountNo(newValue);
if (isDebtAccount(newValue)) {
String accountName = getDebtAccountName(newValue);
String coinName = getCoinName(newValue);
float coinExchange = getCoinExchange(newValue);
bond.setAccountName(accountName);
bond.setCoinName(coinName);
bond.setCoinExchange(coinExchange);
bondTable.getSelectionModel().select(selectedRow, statementCol);
} else if (isNonDebtAccount(newValue)) {
String accountName = getNonDebtAccountName(newValue);
bond.setAccountName(accountName);
bond.setCoinName(getDefaultCoinName());
bond.setCoinExchange(1);
bondTable.getSelectionModel().select(selectedRow, statementCol);
}
else {
System.out.println("wrong acount name");
// show accounts table - i guess
}
} else {
if (newValue.length() == 0) {
System.out.println("length : " + newValue.length());
((Bond) event.getTableView().getItems().get(
event.getTablePosition().getRow())).setAccountNo(newValue);
}
}
}
});
나는이 다음 라인을 사용하려고하지만, 테이블은 새로운 행 해결
bondData.set(selectedRow,Bond);