0

I am having an apex:dataTable and want to add a column which is purely a column of buttons. The button however, will be determined by the status of the record. For example, if the record status is transferring, the button will be cancel. And if the record status is not transferred, the action button will be Transfer.

I don't think it is hard to add those buttons. I can use data-value attribute to capture the status and use javascript to add buttons. But, how can I process those buttons? If a button is clicked, how do I know which record it is related to?

2

You can use regular command buttons in a repeat tag and use the param to pass the id of the record. Control visibility via the rendered tag.

for example:

<table>
<apex:repeat value="{!Itenerable}" var="a">
<tr>
<td>first td</td>
<td>
      <apex:commandButton action="{!cancel_method}" rerender="msgs" value="Cancel" rendered="{!IF(a.Status__c = 'transferring',true,false)}">
           <apex:param assignTo="{!recID}" value="{!a.id}" name="{!a.id}cancel_btn"/>
     </apex:commandButton>
      <apex:commandButton action="{!trandfer_method}" name="Transfer" rerender="msgs" rendered="{!IF(a.Status__c = 'not transfered',true,false)}">
           <apex:param assignTo="{!recID}" value="{!a.id}" name="{!a.id}transfer_btn"/>
     </apex:commandButton>
</td>
</tr>

</apex:repeat>
</table>

You may have to modify for your situation

You could also do it via action function an regular html button(s) as well if needed.

  • Thank you for this - that's actually an easy solution, I just need to put the id into an attribute! I am just wondering why I was stuck there. – Lance Shi Dec 22 '14 at 4:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.