1

I am getting a problem for a field in my tableview where I need to show values from another table dynamically. Below is the code I have used for updating the cell of the tableview. The table is updated with different values than the ones given to them.

              final int k = 0;  
value.setCellValueFactory(new Callback<CellDataFeatures<ObservableList, String>, ObservableValue<String>>() {
    int noOfDataCells = k;
    public ObservableValue<String> call(CellDataFeatures<ObservableList, String> param) 
    {                    

        TableColumn column = param.getTableColumn();
        int size = 0;
        if(tableView1.getItems()!=null)
            size = ((ObservableList) tableView1.getItems().get(0)).size();
        String valueFromData = "";
        if(noOfDataCells<size)
        {
            valueFromData = String.valueOf(((ObservableList) tableView1.getItems().get(0)).get(noOfDataCells));                                                               
        }
        else if(noOfDataCells == size)
        {
            noOfDataCells = 0;
            valueFromData = String.valueOf(((ObservableList) tableView1.getItems().get(0)).get(noOfDataCells));  
        }
        else if (noOfDataCells>size)
        {
            valueFromData = "";
        }
        noOfDataCells++;
        return new SimpleStringProperty(valueFromData);

    }
});             
user1660156
  • 103
  • 1
  • 2
  • 7
  • you may encountered the same issue as an author of this question: http://stackoverflow.com/questions/12352305/java-fx-2-2-tableview-data-changes-as-i-scroll-up-and-down-the-tableview/12425646#12425646 Notice that cell become recreated after scrolling out of visible area and back. So your cell factory should be able to create same cell from given data any time. – Sergey Grinev Sep 19 '12 at 11:46
  • This is different since here there is no updateItem() method but still the data is changing on scrolling up and down the tableview. – user1660156 Sep 24 '12 at 04:56
  • Does anyone have a solution for this one? – user1660156 Oct 25 '12 at 09:03

0 Answers0