aakash_goyal

cell data not rendering

Oct 2nd, 2011
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The resultset rs is well formed and not erroneous. We first create all columns and then add row data to and ObservableList<ObservableList> and finally set it as the data model of the tableview.
  3. */
  4.  
  5.  for(int i=0 ; i<rs.getMetaData().getColumnCount(); i++){
  6.                    TableColumn col = new TableColumn(rs.getMetaData().getColumnName(i+1));
  7.                    
  8.                     col.setCellValueFactory(new Callback<CellDataFeatures<TableView,Object>,Object>(){
  9.                                 public String call(CellDataFeatures<TableView,Object> param) {
  10.                                 int i = param.getIndex();
  11.                                 return ((ObservableList)param.getValue()).get(i).toString();
  12.                                 }
  13.                              });                  
  14.                 tableview.getColumns().add(col);
  15.                 }
  16.                
  17.  
  18.                 /*
  19.                  * Row data to table
  20.                  */
  21.                 while(rs.next()){
  22.                     //Iterate Row
  23.                     ObservableList<Object> row = FXCollections.observableArrayList();
  24.                     for(int i=1 ; i<=rs.getMetaData().getColumnCount(); i++){
  25.                         //Iterate Column
  26.                         row.add(rs.getString(i));
  27.                     }
  28.                     tableData.add(row);
  29.                 }
  30.                
  31.                 // Add tableData to tableView
  32.                 tableview.setItems(tableData);
  33.           }
  34.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×