2014-05-10 2 views
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); 

답변

0

를 추가 한 후 추락 얻을. 문제는 tablecolumn의 리스너로부터 새로운 스테이지를 열려고 할 때 테이블이 추락한다는 것입니다. 그래서 청취자와 불 앞에 나는 새로운 단계를 열어 놓고있는 나의 행동 나는 tablecolumn을 uneditable로 설정했다.

관련 문제