+ Start a Discussion
debradebra 

Show Opportunity products when opportunity is clicked

Trying to create VF Page that will show a list of Opportunities and when user clicks on a row in the list a section below would display the OpportunityLineItems for the selected row in the opportunity list.

Thought was to have a variable in the controller for selected OpportunityID and use this to query the OpportunityLineItem list for the 2nd table however not clear how to set this ID value when user clicks on a row in the opportunity table.    Thinking add action on a column in the row onclick{!setOppID}  but now sure to how to access the selected rows data - I do have a column that contains the ID value.
debradebra
Also looked at option to display products inside the opp table in a column but still missing the part where I can connect the opportunity ID so that only products for the specific opportunity are displayed. RIght now both lists are showing all opportunity line items not for a specific Opportunity.
<apex:page controller="NAOppReviewController" action="{!initializeOppList}" lightningStylesheets="true"  >
	<apex:form >
		<apex:pageBlock >
    		<apex:pageBlockTable value="{!naOpps}" var="o" >
            	<apex:column headerValue="Name" value="{!o.Name}" />
            	<apex:column headerValue="Stage" value="{!o.StageName}" />
           	    <apex:column headerValue="Amount" value="{!o.Amount}" />
                <apex:column headerValue="Close Date" value="{!o.closedate}" />
                <apex:column headerValue="Owner" value="{!o.owner.name}" />
                <apex:column value="{!o.Id}" rendered="false" />
                <apex:column headerValue="Manager Notes" width="500px">
                    <apex:inputTextarea value="{!mgrNotes}" style="width:500px"/>
            	</apex:column>
                <apex:column headerValue="Products">
                        <apex:dataTable  value="{!naOppProducts}" var="p" >
            				<apex:column headerValue="Name" value="{!p.Product2.Name}" />
            				<apex:column headerValue="Price" value="{!p.unitPrice}" />
            				<apex:column headerValue="Quantity" value="{!p.Quantity}" />
            				<apex:column headerValue="Total Price" value="{!p.totalprice}" />
        					<apex:column value="{!p.Id}" rendered="false" />
               			</apex:dataTable>
                 </apex:column>      	
    		</apex:pageBlockTable>
		</apex:pageBlock>
   		<apex:pageBlock >
    		<apex:pageBlockTable value="{!naOppProducts}" var="p" >
            	<apex:column headerValue="Name" value="{!p.Product2.Name}" />
            	<apex:column headerValue="Price" value="{!p.unitPrice}" />
            	<apex:column headerValue="Quantity" value="{!p.Quantity}" />
            	<apex:column headerValue="Total Price" value="{!p.totalprice}" />
        		<apex:column value="{!p.Id}" rendered="false" />
   		 	</apex:pageBlockTable>
		</apex:pageBlock>
    </apex:form>
</apex:page>