Salesforce 如何在pageblocktable行中添加复选框?
我需要在pageblocktable中显示所有自定义对象记录。在填充所有记录之前,我需要添加一个选择列表值,选中第一行中的复选框,然后填充所有记录。我该怎么做呢Salesforce 如何在pageblocktable行中添加复选框?,salesforce,visualforce,apex,Salesforce,Visualforce,Apex,我需要在pageblocktable中显示所有自定义对象记录。在填充所有记录之前,我需要添加一个选择列表值,选中第一行中的复选框,然后填充所有记录。我该怎么做呢 Name Satisfy Opportunity Status Last modified Status(Picklist) Turn on a
Name Satisfy Opportunity Status Last modified
Status(Picklist)
Turn on all checkbox Turn on all checkbox
Clear all Clear all
Test 1 Checkbox Checkbox 12/12/2014
Test 2 Checkbox Checkbox 12/12/2014
Test 3 Checkbox Checkbox 12/12/2014
VF代码:
<apex:page standardcontroller="Opportunity" extensions="oppgapstatus">
<apex:form>
<apex:pageBlock>
<apex:pageBlockSection id="Info">
<apex:pageBlockTable value="{!WrapperList}" var="wraprec">
<apex:column value="{!wraprec.accRec.Name__c}"/>
<apex:column value="{!wraprec.accRec.Satisfied__c}"/>
<apex:column value="{!wraprec.accRec.Current_Status__c}"/>
<apex:column value="{!wraprec.accRec.LastModifiedDate}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:commandbutton value="Save" action="{!UpdateSelectedRecords}"/>
<apex:commandbutton value="Cancel"/>
</apex:pageBlock>
</apex:form>
</apex:page>
顶点类:
Public class oppgapstatus{
Public Opportunity optyList{get;set;}
Public Opportunity_Status__c opst{get;set;}
public PageReference openPresentationOptions() {
return null;
}
private ApexPages.StandardController controller;
public oppgapstatus(ApexPages.StandardController controller) {
}
//Checkbox selectall
Public List<wrapperclass> wrapList {get;set;}
Public boolean checked{get;set;}
Public string selectedField {get;set;}
Public string inputVal{get;set;}
Public void selectallnone(){
if(!checked)
checked = true;
else
checked = false;
}
Public List<wrapperclass> getWrapperList(){
wrapList = New List<wrapperclass>();
for(Opportunity_Status__c acc:[select name,Satisfied__c,Current_Status__c,LastModifiedDate from Opportunity_Gaps__c where Opportunity_Detail__c =: optyList.Id]){
if(!checked)
wrapList.add(New wrapperclass(acc,false));
else
wrapList.add(New wrapperclass(acc,true));
}
return wrapList;
}
Public class wrapperclass{
Public Opportunity_Status__c accRec{get;set;}
Public boolean checkFlag{get;set;}
Public wrapperclass(Opportunity_Status__c acc,boolean flag){
accRec = acc;
checkFlag = flag;
}
}
Public class oppgapstatus{
公共机会选项列表{get;set;}
公共机会状态选择{get;set;}
公共页面引用openPresentationOptions(){
返回null;
}
私有ApexPages.StandardController;
公共机会状态(ApexPages.StandardController){
}
//复选框selectall
公共列表wrapList{get;set;}
公共布尔检查{get;set;}
公共字符串selectedField{get;set;}
公共字符串inputVal{get;set;}
Public void selectallnone(){
如果(!选中)
选中=正确;
其他的
选中=错误;
}
公共列表getWrapperList(){
wrapList=新列表();
对于(Opportunity_Status___c acc:[从Opportunity_Gaps___c中选择名称、满意__c、当前_状态__c、最后修改日期,其中Opportunity_Detail_c=:optyList.Id]){
如果(!选中)
add(新包装类(acc,false));
其他的
add(新的包装类(acc,true));
}
返回包装器;
}
公共类包装器类{
公共机会状态增量{get;set;}
公共布尔检查标志{get;set;}
公共包装器类(Opportunity_Status__c acc,布尔标志){
增大=acc;
checkFlag=标志;
}
}
有人能帮我吗..提前谢谢您只需更改
<apex:column value="{!wraprec.accRec.Name__c}"/>
到
您甚至可以在
<apex:column> <apex:inputCheckbox value="{!wraprec.accRec.boolean_Field__c}"/></apex:column>