0

I want to create a new row in a tableview and open edit for it so the user can access it and write field values. I add the newly created element at the beginning of the table then I focus on the element and edit it. The focus works fine and selects the element correctly, but when I call the edit method it opens the edit for another element. Any suggestions?

//cellFactory for editing functionality for table cells

    Callback cellFactory
            = new Callback() {
        public TableCell call(TableColumn p) {
            return new EditingCell(tableCustomer);
        }
    };

//creating and adding the user to the table 

    Customer newRecord = new Customer(13, "test", "test", "test");
    tableCustomer.getItems().add(0, newRecord);

//focusing on the created element (at the beginning of the table)

    tableCustomer.requestFocus();
    tableCustomer.getSelectionModel().select(0);
    tableCustomer.getFocusModel().focus(0);

//attempting to open edit for the element returns a wrong element

    tableCustomer.edit(0, email);

Sergey Grinev
  • 34,078
  • 10
  • 128
  • 141
m.y.m
  • 347
  • 4
  • 27

0 Answers0