2016-04-15 2 views
0

Excelテーブルのように、ネストされたヘッダーを持つテーブルビューに情報を設定したいとします。Nested Headerを持つテーブルビューの情報をどのように扱うか?

enter image description here

しかし、現在、ちょうどこのようになりますされています:

I can't see all information

しかし、私は

は私が必要とする結果はこのようなものです私を助けることができる何かを得ることなく、時間を過ごしますテーブル内の情報を設定するコード:

JourSuivi j1=new JourSuivi(1, "30/04/2016", 23, 34, new ArrayList<>(), 43, new ArrayList<>(), 345, 23, 2, new ArrayList<>(), 11); 
JourSuivi j2=new JourSuivi(1, "30/04/2016", 23, 34, new ArrayList<>(), 43, new ArrayList<>(), 345, 23, 2, new ArrayList<>(), 11); 
List<Tonnage>ls=new ArrayList<>(); 
ls.add(new Tonnage(ls_ton,"ONCF",33)); 

j1.setNbWgs(ls);j2.setNbWgs(ls); 
List<Double> ls_d=new ArrayList<>(); 
ls_d.add(12.33);ls_d.add(44.2); 

j2.setTocpSA(ls_d);j1.setToncf(ls_d);j1.setToncf(ls_d);j2.setToncf(ls_d); 
ObservableList<JourSuivi> data=FXCollections.observableArrayList(j1,j2); 
table.getColumns().addAll(datecol, expeditionCol,numTrainCol,nWgsCol,totalcol,toncf,totaloncf,nTraincol,tocp,cumul); 
controller.getHb().getChildren().add(table); 
//chargement des données 
table.setItems(data); 

答えて

0

私は本当に質問を理解思ういけないが、これは役立つかもしれない:

@FXML 
TableView<String> tblView; // your table view here 

TableColumn<String, String> columnMain = new TableColumn<>(); 
columnMain.setCellValueFactory(new PropertyValueFactory<>("someValue")); 
columnMain.setText("some text"); 

TableColumn<String, String> columnChild1 = new TableColumn<>(); 
columnChild1 .setCellValueFactory(new PropertyValueFactory<>("someValue")); 
columnChild1 .setText("some text"); 

TableColumn<String, String> columnChild2 = new TableColumn<>(); 
columnChild2 .setCellValueFactory(new PropertyValueFactory<>("someValue")); 
columnChild2 .setText("some text"); 

columnMain.getColumns().add(columnChild1); 
columnMain.getColumns().add(columnChild2); 

// columnMain now has two child columns columnChild1 and columnChild2 

tblView.getColumns().add(columnMain); 

あなたはcolumnChild1に到達したい場合は:あなたはcolumnChild2に到達したい場合は

tblView.getColumns().get(0).getColumns().get(0); 

tblView.getColumns().get(0).getColumns().get(1); 

編集:

あなたがデータを持つテーブルを埋めるためにしたい場合は、これは私のために最善の方法です - > EX、とテーブルを埋めるためにクラスを作成します。

テーブル:

@FXML 
TableView<Person> tblView; 

TableColumn<String, String> columnMain = new TableColumn<>(); 
columnMain.setText("Name"); 

TableColumn<String, String> columnChild1 = new TableColumn<>(); 
columnChild1 .setCellValueFactory(new PropertyValueFactory<>("firstName")); 
columnChild1 .setText("First Name"); 

TableColumn<String, String> columnChild2 = new TableColumn<>(); 
columnChild2 .setCellValueFactory(new PropertyValueFactory<>("lastName")); 
columnChild2 .setText("Last Name"); 

columnMain.getColumns().add(columnChild1); 
columnMain.getColumns().add(columnChild2); 

// columnMain now has two child columns columnChild1 and columnChild2 

tblView.getColumns().add(columnMain); 

とオブジェクト:

public class Person{ 
     String firstName; 
     String lastName; 
     public Person(String firstName,String lastName){ 
      this.firstName=firstName; 
      this.lastName=lastName; 
    } 
} 

テーブルを埋める:

ArrayList<Person> tableData = new ArrayList<>(); 
tableData.add(new Person("Elhassani","Ayoub")); 
tableData.add(new Person("Abdullah","Asendar")); 
tblView.getitems().addAll(tableData); 
+0

は非常にマッチが、それは動作しませステル.but Uに感謝します。実際に私はテーブルに情報を設定したい、と私は以下のコードを使用するが、私はテーブル内のデータが表示されません。 –

+0

情報を設定するコードは次のようになります。 –

+0

ObservableList ob = FXCollections.observableArrayList( "gagga"、 "bbbd"、 "hdgdgd"); \t \t tblView.setItems(ob); –

関連する問題