function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TriptisfdcTriptisfdc 

Can anyone help me

I want to display opportunities of selected Account records in another table on same page using wrapper class.

Thanks
RatanRatan
can you let us know, how far you tried? 
TriptisfdcTriptisfdc
Page
<apex:page controller="Parentchildrecords">
    <apex:form >
        <apex:pageBlock>
            <!--apex:pageBlockButtons >
                <apex:commandButton value="contacts" action="{!showopp}" rerender="table2"/>
            </apex:pageBlockButtons-->
            <!-- In our table we are displaying the cContact records -->
            <apex:pageBlockTable value="{!Accounts}" var="ac" id="table1">
                <apex:column headerValue="Select">  
                    <apex:outputPanel>  
                        <!--<apex:actionSupport event="onclick" action="{!show}" rerender="table3"/>-->  
                            <input type="checkbox" name="det" value="{!ac.selected}"  />  
                      </apex:outputPanel>  
                </apex:column>
                <apex:column value="{!ac.acon.Id}" headerValue="AccountId"/>
                <apex:column value="{!ac.acon.Name}" headerValue="Name"/>
                <apex:column value="{!ac.acon.Type}" headerValue="Type"/>
                <apex:column value="{!ac.acon.Rating}" headerValue="Rating"/>
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
                <apex:commandButton status="fetchStatus" reRender="table1" value="|<" action="{!setCon.first}" disabled="{!!setCon.hasPrevious}" title="First Page"/>
                <apex:commandButton status="fetchStatus" reRender="table1" value="<" action="{!setCon.previous}" disabled="{!!setCon.hasPrevious}" title="Previous Page"/>
                <apex:commandButton status="fetchStatus" reRender="table1" value=">" action="{!setCon.next}" disabled="{!!setCon.hasNext}" title="Next Page"/>
                <apex:commandButton status="fetchStatus" reRender="table1" value=">|" action="{!setCon.last}" disabled="{!!setCon.hasNext}" title="Last Page"/>
                <apex:outputText >
                {!(setCon.pageNumber * size)+1-size}-{!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton status="fetchStatus" reRender="table1" value="Refresh" action="{!refresh}" title="Refresh Page"/>
                <apex:outputPanel>
                    <apex:actionStatus id="fetchStatus" startText="Fetching..." stopText=""/>
                </apex:outputPanel>
            </apex:panelGrid>
            <apex:pageBlockButtons>
                <apex:commandButton value="show" action="{!show}" rerender="table1"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
        <apex:pageBlock id="table3">
            <apex:pageBlockTable value="{!SelectedOpportunity}" var="opp" >
                <apex:column value="{!opp.Name}" />
                <apex:column value="{!opp.stage}" />
            </apex:pageBlockTable>
            
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller
public class wrapperclass{
    //Our collection of the class/wrapper objects AcAccount 
    public List<AcAccount> AccountList {get; set;}
    public List<Account> SelectedAccounts{get;set;}
    public List<Opportunity> SelectedOpportunity{get;set;}
    public List<Id> idl{get;set;}
    public Integer value {get;set;} 
    public wrapperclass(){
        //RecordsPerPageslist=10;
    }
    Public Integer noOfRecords{get; set;}
    Public Integer size{get;set;}
    public ApexPages.StandardSetController setCon {
        get{
            if(setCon == null){
                size = 10;
                string queryString = 'Select Name, Type,rating from Account order by Name';
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));
                setCon.setPageSize(size);
                noOfRecords = setCon.getResultSize();
            }
            return setCon;
        }set;
    }
    public List<AcAccount> getAccounts(){
        if(AccountList == null) {
            AccountList = new List<AcAccount>();
            for(Account ac : [select Id, Name, Type, Rating,(SELECT AccountId, Name, stage FROM Opportunity) from Account]){
                AccountList.add(new AcAccount(ac));
            }
        }
        return AccountList;
        //return (list<AcAccount>)stdSetController.getRecords();
    }  
    public PageReference show(){
        //SelectedAccounts = new List<Account>();
        for(AcAccount acCon : AccountList) {
            //if(acCon.selected == true) {
            idl= new List<Id>();
            idl.add(acCon.acon.id);
        }
        system.debug('ids:'+idl);
        SelectedOpportunity = new List<Opportunity>();
        SelectedOpportunity=[SELECT name,stage from Opportunity where Accountid IN:idl];
        //PageReference pageRef = new PageReference('/apex/mywrapperpage');
        //pageRef.setRedirect(true);
        system.debug('cons:'+SelectedOpportunity);
        return null;
    }
    public pageReference refresh() {
        setCon = null;
            getAccounts();
        setCon.setPageNumber(1);
        return null;
    }
    //system.debug(SelectedOpportunity);
    public class AcAccount{
        public Account acon {get; set;}
        public Boolean selected {get; set;}
        //public List<Id> idl{get;set;}
        public AcAccount(Account ac) {
            acon = ac;
            selected = false;
        }
    }
}