如何解决为什么,当我为输入添加代码时,我的选择列表不起作用
我有自己的控制器和页面。共有三个对象:Doctor__c、Patient__c 和 Appointment__c。预约__c有医生和病人。
我的问题是:当我为 Appointment__c 的 VF 页面中的输入字段添加代码时,我以前的代码无法正常工作。 (我知道要删除部分代码。)
它应该是这样工作的:当我选择 Doctor - Work_Start_Hours 和 End hours 时,表格也应该显示该医生的行。但它不会随着输入字段刷新。
这是一个很大的代码,对不起,但这都是相关的。 这是一个控制器:
public class AppointmentTableController {
public List<Doctor__c> listofDoctors {get;set;}
public String doctorId {get;set;}
public List<Doctor__c> docHoursList {get;set;}
public List<Patient__c> patientList {get;set;}
public String patientId {get;set;}
public Apexpages.StandardSetController controller {get;set;}
public List<Appointment__c> appointmentList {get;set;}
public Appointment__c appointmentObject {get;set;}
public AppointmentTableController() {
listofDoctors = [SELECT Id,Name From Doctor__c ORDER BY Name];
doctorId = listofDoctors.isEmpty() == FALSE ? listofDoctors[0].Id : NULL;
getDoctors();
patientList = [SELECT Id,Name FROM Patient__c ];
getAppointments();
appointmentObject = new Appointment__c();
}
public List<SelectOption> getDoctoRSSelectOptionItems() {
List<SelectOption> options = new List<SelectOption>();
for(Doctor__c d: listofDoctors) {
options.add(new SelectOption(d.Id,d.Name));
}
return options;
}
public void getDoctors() {
docHoursList = [
SELECT Id,Name,Working_Hours_Start__c,Working_Hours_End__c From Doctor__c
Where Id =: doctorId
];
}
public PageReference goToAddNewDoctor() {
return new PageReference('https://vrpconsulting-1d5-dev-ed.lightning.force.com/lightning/o/Doctor__c' +
'/new?count=1&nooverride=1&userecordtypeCheck=1&navigationLocation=LIST_VIEW&uid' +
'=162489093371864736&backgroundContext=%2Flightning%2Fo%2FDoctor__c%2Flist%3FfilterName%3DRecent');
}
//////////////////////////////////////////////////////////////////////////////// Patient
public List<SelectOption> getPatientSelectOptionItems() {
List<SelectOption> options = new List<SelectOption>();
for(Patient__c p: patientList) {
options.add(new SelectOption(p.Id,p.Name));
}
return options;
}
public PageReference goToAddNewPatient() {
return new PageReference('https://vrpconsulting-1d5-dev-ed.lightning.force.com/lightning/o/Patient__c' +
'/new?count=1&nooverride=1&userecordtypeCheck=1&navigationLocation=LIST_VIEW&uid' +
'=162490325260397268&backgroundContext=%2Flightning%2Fo%2FPatient__c%2Flist%3FfilterName%3DRecent');
}
//////////////////////////////////////////////////////////////////////////////// Appointment
public void getAppointments() {
List<Appointment__c> appList = [SELECT Id,Doctor__r.Name,Patient__r.Name,Appointment_Date__c,Duration_in_minutes__c
FROM Appointment__c
WHERE Doctor__r.Id =: doctorId];
controller = new Apexpages.StandardSetController(appList);
controller.setPageSize(20);
appointmentList = (List<Appointment__c>)controller.getRecords();
}
public void saveAppointment() {
appointmentObject.Doctor__c = doctorId;
appointmentObject.Patient__c = patientId;
insert appointmentObject;
appointmentObject = new Appointment__c();
}
}
<apex:page controller="AppointmentTableController">
<apex:form >
<apex:pageBlock title="Appointments Table">
<apex:pageBlock id="Doctor">
<apex:actionFunction action="{!getDoctors}" name="selectDoctors" rerender="DoctorsWorkHours"/>
<apex:actionFunction action="{!getAppointments}" name="selectDoctorAppointments" rerender="AppointmentTable"/>
Select a doctor
<apex:selectList size="1" value="{!doctorId}" onclick="selectDoctors();" onchange="selectDoctorAppointments();">
<apex:selectOptions value="{!doctoRSSelectOptionItems}"/>
</apex:selectList>
<apex:dataList value="{!docHoursList}" var="docHours" id="DoctorsWorkHours">
Working Hours Start <apex:outputField value="{!docHours.Working_Hours_Start__c}"/><br/>
Working Hours End <apex:outputField value="{!docHours.Working_Hours_End__c}"/>
</apex:dataList>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{! goToAddNewDoctor }" value="Add New Doctor" />
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock id="Patient">
Select a patient
<apex:selectList size="1" value="{!patientId}">
<apex:selectOptions value="{!patientSelectOptionItems}"/>
</apex:selectList>
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{! goToAddNewPatient }" value="Add New Patient" />
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock id="Appointment">
HERE THIS CODE
<!-- <apex:pageBlockSection columns="1">
<apex:inputField value="{! appointmentObject.Appointment_Date__c }"/>
<apex:inputField value="{! appointmentObject.Duration_in_minutes__c }"/>
<apex:commandButton action="{!saveAppointment}" value="Add New Appointment"/>
</apex:pageBlockSection> -->
<apex:pageBlockSection columns="1" id="AppointmentTable">
<apex:pageBlockTable value="{!appointmentList}" var="app">
<apex:column headerValue="Action">
</apex:column>
<apex:column value="{!app.Doctor__r.Name}"/>
<apex:column value="{!app.Patient__r.Name}"/>
<apex:column value="{!app.Appointment_Date__c}"/>
<apex:column value="{!app.Duration_in_minutes__c}"/>
</apex:pageBlockTable>
{!Controller.pageNumber} of {! ROUND(controller.resultsize / 5,0)}
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="PrevIoUs" action="{!controller.prevIoUs}" rendered="{!controller.hasPrevIoUs}" />
<apex:commandButton value="Next" action="{!controller.next}" rendered="{!controller.hasNext}" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:pageBlock>
</apex:form>
</apex:page>
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。