Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. <apex:pageBlockSection title="Players" id="wtable">
  2.  
  3. <apex:repeat value="{!lstInner}" var="e1" id="therepeat">
  4.  
  5. <apex:panelGrid columns="4">
  6.  
  7. <apex:panelGrid >
  8. <apex:facet name="header">IsClubCaptain</apex:facet>
  9. <apex:inputCheckbox value="{!e1.player.Club_Captain__c}"/>
  10. </apex:panelGrid>
  11.  
  12. <apex:panelGrid title="Name" >
  13. <apex:facet name="header">Name</apex:facet>
  14. <apex:inputfield value="{!e1.player.Name}"/>
  15. </apex:panelGrid>
  16.  
  17. <apex:panelGrid >
  18. <apex:facet name="header">Jersey Numer</apex:facet>
  19. <apex:inputfield value="{!e1.player.Jersey__c}"/>
  20. </apex:panelGrid>
  21. <apex:panelGrid headerClass="Player">
  22.  
  23. <apex:actionRegion >
  24. <apex:facet name="header">Del</apex:facet>
  25. <apex:commandButton value="X" action="{!Del}" rerender="wtable">
  26. <apex:param name="rowToBeDeleted" value="{!e1.recCount}" assignTo="{!selectedRowIndex}"></apex:param>
  27. </apex:commandButton>
  28. </apex:actionRegion>
  29. </apex:panelGrid>
  30.  
  31. </apex:panelgrid>
  32.  
  33. </apex:repeat>
  34.  
  35. <apex:actionRegion >
  36. <apex:commandButton value="Add Player" action="{!add}" rerender="wtable">
  37.  
  38. </apex:commandButton>
  39. </apex:actionRegion>
  40. </apex:pageblockSection>
  41.  
  42. public Team__c team;
  43.  
  44.  
  45.  
  46. //will hold the player records to be saved
  47. public List<Player__c> players = new List<Player__c>();
  48.  
  49. //list of the inner class
  50. public List<InnerClass> lstInner
  51. { get;set; }
  52.  
  53.  
  54. //will indicate the row to be deleted
  55. public String selectedRowIndex
  56. {get;set;}
  57.  
  58. //no. of rows added/records in the inner class list
  59. public Integer count = 0;
  60.  
  61.  
  62. public CreateTeamController(ApexPages.StandardController controller) {
  63. count = count+1;
  64. this.team = (Team__c)controller.getRecord();
  65. lstInner = new List<InnerClass>();
  66. addMore();
  67. selectedRowIndex = '0';
  68. }
  69.  
  70.  
  71. public PageReference cancel() {
  72. return null;
  73. }
  74.  
  75.  
  76. //add one more row
  77. public PageReference add()
  78. {
  79. system.debug('before add lstInner---->'+this.lstInner.size());
  80. system.debug('player---->'+this.lstInner.get(0).player.name);
  81. count = count+1;
  82. addMore();
  83. return null;
  84. }
  85.  
  86. /*Begin addMore*/
  87. public void addMore()
  88. {
  89. system.debug('count::'+count);
  90. //call to the inner class constructor
  91. innerClass objInnerClass = new innerClass(count);
  92.  
  93. //add the record to the inner class list
  94. this.lstInner.add(objInnerClass);
  95. system.debug('after add lstInner---->'+lstInner.size());
  96. }/* end addMore*/
  97.  
  98. public void Del()
  99. {
  100. system.debug('selected row index---->'+selectedRowIndex);
  101. lstInner.remove(Integer.valueOf(selectedRowIndex)-1);
  102. count = count - 1;
  103. }
  104.  
  105. /*Inner Class*/
  106. public class InnerClass
  107. {
  108. /*recCount acts as a index for a row. This will be helpful to identify the row to be deleted */
  109. public String recCount
  110. {get;set;}
  111.  
  112.  
  113. public Player__c player
  114. {get;set;}
  115.  
  116. /*Inner Class Constructor*/
  117. public InnerClass(Integer intCount)
  118. {
  119. recCount = String.valueOf(intCount);
  120.  
  121. /*create a new player*/
  122. player = new Player__c();
  123.  
  124. }/*End Inner class Constructor*/
  125. }/*End inner Class*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement