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?

1 Answer 1


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:

<apex:repeat value="{!Itenerable}" var="a">
<td>first 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 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"/>


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
    Commented Dec 22, 2014 at 4:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .