在填充表格视图列时,仅填充最后一列,不显示其他列。
这是控制器类,其中填充了表视图,
列出patientList = new ArrayList<>();
try {
System.out.println("I am in table records");
for (AddPatientDto addPatientDtoCopy : editPatientService.fetchPatientsRecord())
{
System.out.println(addPatientDtoCopy.getPatinet_id() + addPatientDtoCopy.getFirstName()+ addPatientDtoCopy.getMiddleName()+
addPatientDtoCopy.getLastName()+ addPatientDtoCopy.getAreaInp()+ addPatientDtoCopy.getQualification());
patientList.add(new PatientDto(addPatientDtoCopy.getPatinet_id(), addPatientDtoCopy.getFirstName(), addPatientDtoCopy.getMiddleName(),
addPatientDtoCopy.getLastName(), addPatientDtoCopy.getAreaInp(), addPatientDtoCopy.getQualification()));
enter code here
}
ObservableList<PatientDto> observeTableDataList = FXCollections.observableArrayList(patientList);
System.out.println(observeTableDataList.subList(0, 14));
TableColumn patient_id = new TableColumn("PatientID");
patient_id.setMinWidth(100);
patient_id.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("Patient_id"));
patient_id.setVisible(true);
TableColumn first_name = new TableColumn("FirstName");
first_name.setMinWidth(100);
// patient_name.setCellValueFactory(new PropertyValueFactory<AddPatientDto, String>("first_name" + " " + "middle_name" + " " + "last_name"));
first_name.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("first_name"));
first_name.setVisible(true);
TableColumn middle_name = new TableColumn("MiddleName");
middle_name.setMinWidth(100);
middle_name.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("middle_name"));
middle_name.setVisible(true);
TableColumn last_name = new TableColumn("LastName");
last_name.setMinWidth(100);
last_name.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("last_name"));
last_name.setVisible(true);
TableColumn patient_location = new TableColumn("Location");
patient_location.setMinWidth(100);
patient_location.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("Area"));
patient_location.setVisible(true);
TableColumn patient_qualification = new TableColumn("Qualification");
patient_qualification.setMinWidth(100);
patient_qualification.setCellValueFactory(new PropertyValueFactory<PatientDto, String>("Qualification"));
patient_qualification.setVisible(true);
patientsDetails.setItems(observeTableDataList);
patientsDetails.getColumns().setAll(patient_id, first_name, middle_name, last_name, patient_location, patient_qualification);
patientsDetails.setVisible(true);
System.out.println("End of table records");
} catch (Exception e) {
e.printStackTrace();
}
此DTO类,其中正在获取/设置对象值
公共课PatientDto {
private SimpleStringProperty patinet_id;
private SimpleStringProperty firstName;
private SimpleStringProperty middleName;
private SimpleStringProperty lastName;
private SimpleStringProperty areaInp;
private SimpleStringProperty qualification;
public PatientDto() {
}
public PatientDto(String patientId, String FirstName, String MiddleName, String LastName, String Location, String Qualification) {
this.patinet_id = new SimpleStringProperty(patientId);
this.firstName = new SimpleStringProperty(FirstName);
this.middleName = new SimpleStringProperty(MiddleName);
this.lastName = new SimpleStringProperty(LastName);
this.areaInp = new SimpleStringProperty(Location);
this.qualification = new SimpleStringProperty(Qualification);
}
/**
* @return the patinet_id
*/
public String getPatinet_id() {
return patinet_id.get();
}
/**
* @param patinet_id the patinet_id to set
*/
public void setPatinet_id(String patinet_id) {
this.patinet_id.set(patinet_id);
}
/**
* @return the firstName
*/
public String getFirstName() {
return firstName.get();
}
/**
* @param firstName the firstName to set
*/
public void setFirstName(String firstName) {
this.firstName.set(firstName);
}
/**
* @return the middleName
*/
public String getMiddleName() {
return middleName.get();
}
/**
* @param middleName the middleName to set
*/
public void setMiddleName(String middleName) {
this.middleName.set(middleName);
}
/**
* @return the lastName
*/
public String getLastName() {
return lastName.get();
}
/**
* @param lastName the lastName to set
*/
public void setLastName(String lastName) {
this.lastName.set(lastName);
}
/**
* @return the areaInp
*/
public String getAreaInp() {
return areaInp.get();
}
/**
* @param areaInp the areaInp to set
*/
public void setAreaInp(String areaInp) {
this.areaInp.set(areaInp);
}
/**
* @return the qualification
*/
public String getQualification() {
return qualification.get();
}
/**
* @param qualification the qualification to set
*/
public void setQualification(String qualification) {
this.qualification.set(qualification);
}
}