2015-04-15 2 views
0

Позвольте мне сначала объяснить, что я сделал.Связать столбец с данными javafx

  1. Я имею список таблиц в раскрывающемся
  2. , когда кто-то выбрать любой он будет заполнять все данные Tableview по имени столбца

я в состоянии получить столбцы из таблицы и поместить ее в таблицу, но я не могу связать данные со связанными столбцами.

Мой код здесь, чтобы посмотреть

 this.tableName = clsComboData.getValue(); 

    System.out.println(tableName); System.out.println("Button Pressed"); 
    List<StaticColumnConfig> allColumns = null; 
    for(StaticDataTable dataTable : dropdown) { 
     if(dataTable.getTableName() != null && dataTable.getTableName().equalsIgnoreCase(tableName)) { 
      System.out.println(dataTable.getColumnConfig()); 
      allColumns = dataTable.getColumnConfig(); 
     } 
    } 

    switch (tableName) { 
    case "IOSwapCounterparties": SimpleDateFormat date = new SimpleDateFormat("2015-04-15"); 
            System.out.println("Into the Switch"); 
            data = FXCollections.observableArrayList(
             new IOSwapCounterparties(1,"a","b","c","d","e",date), 
             new IOSwapCounterparties(1,"aa","bb","cv","dd","es",date), 
             new IOSwapCounterparties(1,"ad","bd","cd","dc","eb",date), 
             new IOSwapCounterparties(1,"aw","bw","cr","dt","ey",date), 
             new IOSwapCounterparties(1,"ag","bt","cy","du","ep",date) 
            ); 
      break; 
    } 

    //System.out.println("Its in ELSE");    
    //"Invited" column 
    TableColumn checkboxCol = new TableColumn<Person, Boolean>(); 

    checkboxCol.setText(""); 

    checkboxCol.setMinWidth(50); 

    checkboxCol.setCellValueFactory(new PropertyValueFactory("checkbox")); 
    // Create checkboxes 
    checkboxCol.setCellFactory(new Callback<TableColumn<Person, Boolean>, TableCell<Person, Boolean>>() { 
     public TableCell<Person, Boolean> call(TableColumn<Person, Boolean> p) { 

      CheckBoxTableCell<Person, Boolean> checkBox = new CheckBoxTableCell();    
      return checkBox; 

     } 
    });   

    //Set cell factory for cells that allow editing 
    Callback<TableColumn, TableCell> cellFactory = 
     new Callback<TableColumn, TableCell>() { 
     public TableCell call(TableColumn p) { 

      return new EditingCell(); 

     } 
    }; 

    for(StaticColumnConfig column : allColumns){         
     TableColumn oneColumn = new TableColumn(column.getColumnName()); 
     oneColumn.setCellFactory(cellFactory); 
    } 

    // Clear the tableview for next table 
    tblViewer.getColumns().clear();  
    // Push the data to the tableview 
    tblViewer.setItems(data);   
    tblViewer.setEditable(true); 

    tblViewer.getColumns().addAll(checkboxCol); 
    for(StaticColumnConfig column : allColumns){ 
     System.out.println(column.getColumnName()); 

     TableColumn oneColumn = new TableColumn(column.getColumnName()); 
     tblViewer.getColumns().addAll(oneColumn); 

    } 

    // Add the columns 
    tblViewer.getSelectionModel().setCellSelectionEnabled(true);    
    tblViewer.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); 
+0

Я понял решение. – php83

ответ

0

Там это было в верхнем регистре - строчную ошибка с моей геттер и сеттер метода.

Смежные вопросы