2

What I'm trying to do is rerender my form once a row in the table is clicked. Initially, I have just put a system debug line in the function in the controller and I have not been able to see it in the debug log since the action support is not going there. Not sure why honestly...

VF Page :

<apex:column width="50px;">
  <apex:facet name="header">Name</apex:facet>
     <apex:outputpanel>
         <apex:actionSupport event="onRowClick" action="{!setSource}" reRender="form">
           <apex:param name="temp.name" value="{!temp.Name}"/>
           <apex:param name="temp.id" value="{!temp.ID}"/>
          </apex:actionSupport>
     {!temp.Name}
     </apex:outputpanel>
</apex:column>

Btw, this column is part of an apex page block table :

<apex:pageBlockTable rows="5" rendered="{!selectedObject=='ACCOUNT' && foundResults==true}"
value="{!searchResultsAcc}" var="temp">

Function in controller :

public void setSource() {
   System.debug('Inside setSource()');
}
0

1 Answer 1

1

onRowClick is only when you're using apex:dataTable or apex:pageBlockTable. You can't use it with apex:actionSupport. You'll probably want to just use "onclick" as the event.


Working demo of passing a value back to the row-click:

<apex:page standardController="Account" recordSetVar="Accounts">
    <apex:form>
        <apex:pageBlock>
        <apex:pageBlockTable value="{!accounts}" var="accountRecord" onrowclick="alert(this.firstChild.dataset.id)">
            <apex:column html-data-id="{!accountRecord.Id}" value="{!accountRecord.Name}" />
        </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

You can call an actionFunction (not shown here) to pass parameters to the controller.


Demo calling actionFunction:

Controller:

public class highlightRowController {
    public Id selectedId { get; set; }
    public Integer selectCount { get; set; }
    public highlightRowController() {
        selectCount = 0;
    }
    public Account[] getAccounts() {
        return [SELECT Id, Name FROM Account ORDER BY Name ASC LIMIT 100];
    }
    public void incrementCounter() {
        selectCount++;
    }
}

Page:

<apex:page controller="highlightRowController">
    <apex:form id="form">
        <apex:actionFunction name="highlightRow" reRender="form" action="{!incrementCounter}">
            <apex:param name="selectedId" assignTo="{!selectedId}" value="" />
        </apex:actionFunction>
        <apex:pageBlock title="Times function called: {!selectCount}">
            <apex:pageBlockTable value="{!accounts}" var="account" onrowclick="highlightRow(this.firstChild.dataset.id)">
                <apex:column value="{!account.Name}{!if(selectedId=account.Id,' (Selected)','')}" html-data-id="{!account.Id}" />
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
0

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.