I have TableView with number of columns, I have set onEditCommit method on the first column to get the value inserted and then retrieve data from database based on that value and set the retrieved data in other columns. the table couldn't update it's content.

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);
                }
            }
        }
    });

I tried to use this next line but the table get crashed after adding new rows

bondData.set(selectedRow,Bond);
有帮助吗?

解决方案

Solved. The problem was the table get crashed when am trying to open new stage from a listener on a tablecolumn. so on listener and before fire my action which is opening new stage i set the tablecolumn uneditable.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top