[SalesForce] How to get the selected records from the related list

I have custom object and which is a lookup to Quote.

1)I have created a "MassEdit" list button on the related list (Child object).

2) I am unable to retrieve the records (Child records) from the (Parent record) .

For Example :I have parent record say "pt1" and it has 2 child records in the related list say "ch1,ch2".Now when the user clicks on the "MASSEDIT" button on the related list ,it should open the records "ch1.ch2" to edit.After necessary changes the user will save the record.So how can i do this.I shall appreciate your help.
Any suggestion plz.

Followed this Example :
http://www.infallibletechie.com/2014/05/how-to-get-selected-records-from.html

VF CODE :

<apex:page StandardController="Compitetor__c" sidebar="false" recordSetVar="Compitetors"     extensions="CompitetorsEditExt">
 <apex:form >
  <apex:sectionHeader title="Edit for Competitor"/>
  <apex:pageBlock title="Quote Update"  mode="Edit">
   <apex:pageBlockButtons >
    <apex:commandButton action="{!SAVE}" value="SAVE"/>
    <apex:commandButton action="{!CANCEL}" value="CANCEL"/>
   </apex:pageBlockButtons>
    <apex:pageBlockTable value="{!selected}" var="com">
    <apex:column >
    <apex:inputField value="{!com.Name}"/>
    </apex:column>
 <apex:column >
   <apex:inputField value="{!com.Product_Series__c}" />
   </apex:column>
  </apex:pageBlockTable>
  </apex:pageBlock>
 </apex:form>
    </apex:page>

Apex Class :

public  class CompitetorsEditExt {

    public CompitetorsEditExt(ApexPages.StandardSetController controller) {
     controller.setPageSize(10);

    }
}

Best Answer

If you mean that you want to get the selected records in the controller then you can use the methods of the standard controller such as getSelected like this:

public  class CompitetorsEditExt {

    private ApexPages.StandardSetController sc;

    public CompitetorsEditExt(ApexPages.StandardSetController sc) {
        this.sc = sc;
        sc.setPageSize(10);
    }

    private Compitetor__c[] getSelected() {
        return (Compitetor__c[]) sc.getSelected();
    }

    private void someOtherMethod() {
        Compitetor__c[] competitors = getSelected();
        ...
    }
}
Related Topic