Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <apex:pageBlockSection title="Players" id="wtable">
- <apex:repeat value="{!lstInner}" var="e1" id="therepeat">
- <apex:panelGrid columns="4">
- <apex:panelGrid >
- <apex:facet name="header">IsClubCaptain</apex:facet>
- <apex:inputCheckbox value="{!e1.player.Club_Captain__c}"/>
- </apex:panelGrid>
- <apex:panelGrid title="Name" >
- <apex:facet name="header">Name</apex:facet>
- <apex:inputfield value="{!e1.player.Name}"/>
- </apex:panelGrid>
- <apex:panelGrid >
- <apex:facet name="header">Jersey Numer</apex:facet>
- <apex:inputfield value="{!e1.player.Jersey__c}"/>
- </apex:panelGrid>
- <apex:panelGrid headerClass="Player">
- <apex:actionRegion >
- <apex:facet name="header">Del</apex:facet>
- <apex:commandButton value="X" action="{!Del}" rerender="wtable">
- <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
- </apex:commandButton>
- </apex:actionRegion>
- </apex:panelGrid>
- </apex:panelgrid>
- </apex:repeat>
- <apex:actionRegion >
- <apex:commandButton value="Add Player" action="{!add}" rerender="wtable">
- </apex:commandButton>
- </apex:actionRegion>
- </apex:pageblockSection>
- public Team__c team;
- //will hold the player records to be saved
- public List<Player__c> players = new List<Player__c>();
- //list of the inner class
- public List<InnerClass> lstInner
- { get;set; }
- //will indicate the row to be deleted
- public String selectedRowIndex
- {get;set;}
- //no. of rows added/records in the inner class list
- public Integer count = 0;
- public CreateTeamController(ApexPages.StandardController controller) {
- count = count+1;
- this.team = (Team__c)controller.getRecord();
- lstInner = new List<InnerClass>();
- addMore();
- selectedRowIndex = '0';
- }
- public PageReference cancel() {
- return null;
- }
- //add one more row
- public PageReference add()
- {
- system.debug('before add lstInner---->'+this.lstInner.size());
- system.debug('player---->'+this.lstInner.get(0).player.name);
- count = count+1;
- addMore();
- return null;
- }
- /*Begin addMore*/
- public void addMore()
- {
- system.debug('count::'+count);
- //call to the inner class constructor
- innerClass objInnerClass = new innerClass(count);
- //add the record to the inner class list
- this.lstInner.add(objInnerClass);
- system.debug('after add lstInner---->'+lstInner.size());
- }/* end addMore*/
- public void Del()
- {
- system.debug('selected row index---->'+selectedRowIndex);
- lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
- count = count - 1;
- }
- /*Inner Class*/
- public class InnerClass
- {
- /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
- public String recCount
- {get;set;}
- public Player__c player
- {get;set;}
- /*Inner Class Constructor*/
- public InnerClass(Integer intCount)
- {
- recCount = String.valueOf(intCount);
- /*create a new player*/
- player = new Player__c();
- }/*End Inner class Constructor*/
- }/*End inner Class*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement