You need to sign in to do that
Don't have an account?
Patrick Sluck 5
Select multiple contacts in visualforce
I am working on a VF Page for "Trip Reports", eseentially visits. I would like to select multiple contacts from the account associated to the Trip Report Object. I have gotten to a point where I can see my, "Add Attendees" button, but it is not rendering a table of contacts to select. Once I figure this out I need to do the same with Users. Any assistance would be greatly appreciated!!!!
Below is my code.
<apex:page standardController="Trip_Report__c" extensions="ReturnToObject" >
<style>
.activeTab {background-color: #2ECCFA; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<script>
function confirmSave() {
var isSave = confirm("Your Trip Report has been saved!");
if (isSave) return true;
return false;
}
</script>
<!-- Include reference for jQuery -->
<apex:includeScript value="{!URLFOR($Resource.jQuery,'js/jquery-1.7.2.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery2, 'js/jquery-ui-1.8.19.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jQuery2, 'css/ui-lightness/jquery-ui-1.8.19.custom.css')}"/>
<script type="text/javascript">
var j$= jQuery.noConflict();
j$(document).ready(function(){
j$('#openContactDialog').click(function(){
j$('#contactListDialog').dialog({
buttons:{'Ok': function(){ j$(this).dialog("close");},'Cancel':function(){}
}, modal:true,title:"contacts",width:800, closeOnEscape:true, draggable:false, resizable:false,show:"fade",position:"center"});
});
});
function openContactListDialog() {
j$("#contactListDialog")
.find("input:checked")
.each(function() {
this.checked = false;
})
.end()
.dialog("open");
}
</script>
<apex:form >
<apex:pageBlock title="Trip Report">
<apex:pageBlockButtons >
<apex:commandButton value="Save As Draft" action="{!saveAndReturn}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton action="/flow/TR Has Been Submitted" value="Submit" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:outputfield value="{!Trip_Report__c.Account__c}"/>
<apex:inputfield required="true" value="{!Trip_Report__c.Name}" label="Visit"/>
<font style="margin-left:240px" size="0.25" color="blue"> <b> Enter: 'TR'-Company Name-Subject for the Visit</b></font>
<apex:inputfield required="true" value="{!Trip_Report__c.Purpose_of_Visit__c}" label="Purpose Of Visit"/>
<apex:inputfield value="{!Trip_Report__c.Visit_Date__c}" label="Date"/>
<apex:inputfield value="{!Trip_Report__c.Lead_Source__c}" label="Lead Source"/>
<apex:inputfield value="{!Trip_Report__c.Opportunity__c}" label="Opportunity"/>
<apex:inputfield value="{!Trip_Report__c.Campaign__c}" label="Campaign"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:form rendered="{!ISNULL(Trip_Report__c.Attendees__c)}">
<apex:pageBlock title="Attendees">
<apex:pageBlockSection columns="3">
<apex:outputPanel layout="block">
<div>
<input type="button" value="Delete"/>
<input type="button" value=" Add Attendee(s)" id="openContactDialog" />
<input type="button" value="Add PL Attendee(s)"/>
</div>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<div id="contactListDialog" style="display: none;">
<apex:form id="contactListForm">
<apex:outputPanel styleClass="dataGrid" layout="block" >
<table id="contactListTable" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="first" scope="col"><img src="/s.gif" alt="" border="0" width="1" height="1" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Name.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.title.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Phone.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Email.Label}" /></th>
</tr>
</thead>
</table>
</apex:outputPanel>
</apex:form>
</div>
<apex:form >
<div>
<apex:pageBlock title="Trip Details & Notes">
<apex:tabPanel switchType="client" selectedTab="sch" tabclass="activeTab" inactivetabclass="inactiveTab">
<apex:tab label="Objectives">
<apex:inputfield value="{!Trip_Report__c.Objectives__c}" label="Objectives/Reason For Visit" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Background">
<apex:inputfield value="{!Trip_Report__c.Background__c}" label="Background Information" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Discussions">
<apex:inputfield value="{!Trip_Report__c.Discussion__c}" label="Discussions" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Trip Summary">
<apex:inputfield value="{!Trip_Report__c.Summary__c}" label="Trip Summary" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Actions/Questions">
<apex:inputfield value="{!Trip_Report__c.Actions_Questions__c}" label="Actions/Questions" style="width: 1250px; height: 100px"/>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</div>
</apex:form>
</apex:page>
Below is my code.
<apex:page standardController="Trip_Report__c" extensions="ReturnToObject" >
<style>
.activeTab {background-color: #2ECCFA; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<script>
function confirmSave() {
var isSave = confirm("Your Trip Report has been saved!");
if (isSave) return true;
return false;
}
</script>
<!-- Include reference for jQuery -->
<apex:includeScript value="{!URLFOR($Resource.jQuery,'js/jquery-1.7.2.min.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.jQuery2, 'js/jquery-ui-1.8.19.custom.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.jQuery2, 'css/ui-lightness/jquery-ui-1.8.19.custom.css')}"/>
<script type="text/javascript">
var j$= jQuery.noConflict();
j$(document).ready(function(){
j$('#openContactDialog').click(function(){
j$('#contactListDialog').dialog({
buttons:{'Ok': function(){ j$(this).dialog("close");},'Cancel':function(){}
}, modal:true,title:"contacts",width:800, closeOnEscape:true, draggable:false, resizable:false,show:"fade",position:"center"});
});
});
function openContactListDialog() {
j$("#contactListDialog")
.find("input:checked")
.each(function() {
this.checked = false;
})
.end()
.dialog("open");
}
</script>
<apex:form >
<apex:pageBlock title="Trip Report">
<apex:pageBlockButtons >
<apex:commandButton value="Save As Draft" action="{!saveAndReturn}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
<apex:commandButton action="/flow/TR Has Been Submitted" value="Submit" />
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:outputfield value="{!Trip_Report__c.Account__c}"/>
<apex:inputfield required="true" value="{!Trip_Report__c.Name}" label="Visit"/>
<font style="margin-left:240px" size="0.25" color="blue"> <b> Enter: 'TR'-Company Name-Subject for the Visit</b></font>
<apex:inputfield required="true" value="{!Trip_Report__c.Purpose_of_Visit__c}" label="Purpose Of Visit"/>
<apex:inputfield value="{!Trip_Report__c.Visit_Date__c}" label="Date"/>
<apex:inputfield value="{!Trip_Report__c.Lead_Source__c}" label="Lead Source"/>
<apex:inputfield value="{!Trip_Report__c.Opportunity__c}" label="Opportunity"/>
<apex:inputfield value="{!Trip_Report__c.Campaign__c}" label="Campaign"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:form rendered="{!ISNULL(Trip_Report__c.Attendees__c)}">
<apex:pageBlock title="Attendees">
<apex:pageBlockSection columns="3">
<apex:outputPanel layout="block">
<div>
<input type="button" value="Delete"/>
<input type="button" value=" Add Attendee(s)" id="openContactDialog" />
<input type="button" value="Add PL Attendee(s)"/>
</div>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<div id="contactListDialog" style="display: none;">
<apex:form id="contactListForm">
<apex:outputPanel styleClass="dataGrid" layout="block" >
<table id="contactListTable" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="first" scope="col"><img src="/s.gif" alt="" border="0" width="1" height="1" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Name.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.title.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Phone.Label}" /></th>
<th scope="col"><apex:outputText value="{!$ObjectType.Contact.Fields.Email.Label}" /></th>
</tr>
</thead>
</table>
</apex:outputPanel>
</apex:form>
</div>
<apex:form >
<div>
<apex:pageBlock title="Trip Details & Notes">
<apex:tabPanel switchType="client" selectedTab="sch" tabclass="activeTab" inactivetabclass="inactiveTab">
<apex:tab label="Objectives">
<apex:inputfield value="{!Trip_Report__c.Objectives__c}" label="Objectives/Reason For Visit" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Background">
<apex:inputfield value="{!Trip_Report__c.Background__c}" label="Background Information" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Discussions">
<apex:inputfield value="{!Trip_Report__c.Discussion__c}" label="Discussions" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Trip Summary">
<apex:inputfield value="{!Trip_Report__c.Summary__c}" label="Trip Summary" style="width: 1250px; height: 100px"/>
</apex:tab>
<apex:tab label="Actions/Questions">
<apex:inputfield value="{!Trip_Report__c.Actions_Questions__c}" label="Actions/Questions" style="width: 1250px; height: 100px"/>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</div>
</apex:form>
</apex:page>
Could you copy/paste the apex extension ReturnToObject ?
The current javascript (jquery) part openContactDialog and openContactListDialog does nearly nothing.
<input type="button" value=" Add Attendee(s)" id="openContactDialog" />
j$('#openContactDialog').click(function(){
I simplified your code for a test suppressing none for the display of the div contactListDialog (that could help other developers here).
<div id="contactListDialog" style="display:">
if you click on "Add Attendee(s)":
.
It is just a demo because it seems that you want to unckeck the input into the div contactListDialog ?
function openContactListDialog() {
j$("#contactListDialog")
.find("input:checked")
Best regards
Alain